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.
Hi Guys
I've created a dax formula for calculating a rolling 12 sum of [belopp tUSD]. The table contains data from 2016-04-01 and I have two conditions for the report:
* only show the R12-value if there is 12 months worth of data to measure
* dont show the R12-value if there isnt any monthly data available (dont want to measure the future R12)
The formula below works fine, however the table is going to be huge so I want to optimize the report for speed, I get the feeling having two IF-checks isnt ideal. Any suggestions for improvement is highly appreciated as I'm very new to the coding.
First IF, check if the number of "monthname" is below <12
second IF, check if the montly sum = blank(), then return blank for the R12-measure
tUSD R12:=
IF(
CALCULATE(
COUNTROWS(VALUES(calender[MonthName]));
datesbetween(calender[Datum];
CALCULATE(firstdate(ALL(Levreskontra[InvoiceDate]));Levreskontra[Currency]="USD");
LASTDATE(calender[Datum]))
)
<12;BLANK();
IF([Belopp tUSD]=BLANK();BLANK();
calculate([Belopp tUSD];
datesbetween(calender[Datum];
NEXTDAY ( SAMEPERIODLASTYEAR ( LASTDATE (calender[Datum])));
LASTDATE(calender[Datum]))))
)
You can just try to wrap the two IF into one, thought I don't think it won't make much difference. Any acutally performance issue you've encountered?
tUSD R12 := IF ( CALCULATE ( COUNTROWS ( VALUES ( calender[MonthName] ) ), DATESBETWEEN ( calender[Datum], CALCULATE ( FIRSTDATE ( ALL ( Levreskontra[InvoiceDate] ) ), Levreskontra[Currency] = "USD" ), LASTDATE ( calender[Datum] ) ) ) < 12 || [Belopp tUSD] = BLANK (), BLANK (), CALCULATE ( [Belopp tUSD], DATESBETWEEN ( calender[Datum], NEXTDAY ( SAMEPERIODLASTYEAR ( LASTDATE ( calender[Datum] ) ) ), LASTDATE ( calender[Datum] ) ) ) )
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 |
---|---|
114 | |
99 | |
83 | |
70 | |
60 |
User | Count |
---|---|
150 | |
115 | |
104 | |
89 | |
65 |