Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
If you had asked me this morning whether there would be any difference between writing a DAX statement in a separate measure and referencing it to directly into your DAX code, I would have told you there wasnt. I would have been wrong.
To showcase this, I was writing a measure today with the purpose of returning the Average of the total Revenue of each month. Here is the first formula i tried:
Average Revenue = IF( COUNTROWS(VALUES('Monthly Sales'[YearMonth])) = 1, SUM('Monthly Sales'[TOTALS]), AVERAGEX( VALUES('Monthly Sales'[YearMonth]), SUM('Monthly Sales'[TOTALS]) ) )
This does not provide the correct answer. So, i took the SUM portion of the function and made it a measure. This gave me:
Revenue = SUM('Monthly Sales'[TOTALS])
Average Revenue = IF( COUNTROWS(VALUES('Monthly Sales'[YearMonth])) = 1, [Revenue], AVERAGEX( VALUES('Monthly Sales'[YearMonth]), [Revenue] ) )
This change now gives me the correct answer.
I thought it was a good topic to highlight and share.
Hi @Anonymous,
It's really a good idea, thanks for sharing it.
Best Regards,
Angelia
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
108 | |
100 | |
78 | |
64 | |
58 |
User | Count |
---|---|
148 | |
111 | |
94 | |
84 | |
67 |