Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.
Hello Community. This post describes (and provides) a simple model that is useful for learning and/or troubleshooting. It is a self-contained pbix file (i.e., the whole model is generated with M and DAX, with no external data connections). This is a small model (<1 Mb) that can be used as a "sandbox" to test stuff out. Below is a description of what it contains:
Tables
Measures
Relationships
There is one measure/approach in the model I'd like to call attention to that I think is good for people learning DAX to know about (whether they use this model or not). I plan a more detailed post soon, but getting your expected results from almost all DAX expressions requires you to understand 3 things:
For Time Intelligence DAX expressions (and Date-related ones in general), you can visualize #2 with the below measure. It is useful for troubleshooting to confirm you are making the table you meant to make before you even worry about #3.
MinMaxDates =
MIN ( 'Date'[Date] ) & "-"
& MAX ( 'Date'[Date] )
For example, here it is used in a larger expression (shown below table) to calculate a running total for the current year. It shows that the table of Date values in the filter part of the CALCULATE() is correct. Now that we know that, we can now focus on the expression part and replace [MinMaxDates] with the needed expression (a [Total Sales] measure in this case, or something more complicated). This is a simple example, but this approach might be useful for people just starting out, or for experienced people working on a new way to make a table of Dates for a filter.
Running Total This Year =
CALCULATE (
[MinMaxDates],
FILTER ( ALL ( 'Date'[Date] ), 'Date'[Date] <= MAX ( 'Date'[Date] ) ),
VALUES ( 'Date'[Year] )
)
// there are easier ways to do running totals but this was a good example for troubleshooting
I use this model sometimes when answering Community Posts, and I hope new Power BI users can use it to practice/see examples and/or experts can use it to demonstrate concepts. It is easily expandable and adaptable, so feel free to make it better. There is a lot more that could be done with example measures, and I didn't do anything on visuals, design, etc. My main focus was to create a self-contained and simple model for people to practice basic DAX concepts
.
Please find the Sandbox.pbix file attached and reply with comments/questions or suggestions for improvement. Kudos are also appreciated.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.