A big Hello to everyone at the Excel Club! I am thrilled and honored to share my learning from the Power BI world with you folks.
In this post, I am going to share 9 awesome tips on DAX and Power BI. These tricks cover some of the common problems ranging from auditing DAX measures to enhancing productivity. Let's dive right in! Enjoy!
DAX Data view is quite inflexible (as compared to Excel) for the sole reason that you can't write formulas in a cell. Amidst your modeling exercise, you'll feel the need to copy the data from Power BI to Excel. Here is how you can do that.
Copying data to Excel is one of the easiest ways I have been able to fix errors and of course, write better DAX.
Note - If the copied data exceeds the number of rows in an excel sheet, the data would truncate in the last row.
Side Note - Here is more comprehensive post on copying and pasting data in Power BI
This tip extends from TIP 1. What if the number of copied rows exceeds the capacity of Excel. In that case, you can create a dummy table to get aggregation on your table. Let me explain…
Consider the filtered table below that you can't copy in Excel.
You want to sum the Units column. How do you do that in Power BI ?
I am going to create a one-row table to sum Units for Mumbai.
Quick Summary Table =
ROW (
"SUM of Mumbai",
CALCULATE (
SUM ( Sales[Units] ),
Sales[Region] = "Mumbai"
)
)
You can see the output is the SUM of Units for Mumbai.
Here is a quick explanation
This technique can come very handy if you quickly want to summarize your data in Power BI.
If you are a graduate of Excel, now using Power BI. You'd often have wondered how can I write an excel-like COUNTIF in Power BI. Unfortunately, there is no COUNTIF function in Power BI, but that doesn't mean that you can't write it.
A few considerations
Consider this data that we have been using..
I'd like to find the COUNT of Dates. Against 2nd Jan, I should get the count 2 and so on..
COUNTIF for Date =
COUNTROWS(
FILTER(
ALL(Sales),
EARLIER(Sales[Date]) = Sales[Date]
)
)
Result..
Quick Explanation -
So that's how you do a COUNTIF. I have a lot more scenarios for COUNTIF explained here
My god.. this is big one! Writing DAX can be tedious.. deleting a part of the formula, moving codes around..
I have put together a comprehensive list of DAX Keyboard shortcuts and guess what they even work in Power Query (M Code) too. My favorite ones are - 4, 5, 6, 7, 9
I'd need a bit of explaining here. Consider this Pivot and a simple measure
Since no sale happened on 1st Jan, the label doesn't appear but what if I want to see the label whether or not the sale happened. This can be achieved with a simple DAX trick.
Just add (+) a 0 at the end of your code. Bingo!
If you have tried a table named Measures, Power BI doesn't like that and won't allow it. But you can. Let me first give the credit to Phil Seamark, I learned this trick on his blog
[ Measures] = {BLANK()}
Note the little Space before " Measures". Don't worry that'll be truncated when the table is created!
Power BI doesn't let you type data. But you can! Here is a quick one!
Caution :
This technique is super helpful when you have created a ton of measures and want to segregate them. You can use Folders. Here is how it works
This is a super cool method to organize your measures in one place.
If you have created enough visuals with Power BI, you know what tooltips are (the little window that appears with additional info on a mouse hover). Similarly, you can create documentation that appears when you hover over the Measure. You'd understand better when you see it.
Comment below with 2 things.
Chandeep is a fellow Power BI / Excel enthusiast based in Gurgaon (India). His work focuses on training & consulting companies on implementing Power BI solutions. He is an avid blogger and writes about Excel, Charting, DAX, M and Power BI on his blog
DAX AND OR IN or syntax(&& ||) – Which one?
6 DAX tips for Excel and Power BI users
If you would like to start collecting rewards quickly for learning Excel then you should try:
10+ Excel Learn and Earn Activities YOU can do Today