Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi all,
I'm currently trying to optimize a measure that takes a while to load :
MyMeasure:=
CALCULATE (
[Submeasure],
USERELATIONSHIP ( Sales[IdMember], 'Members'[IdMember] ),
FILTER (
'Members',
'Members'[Metier] <> "Chef"
&& 'Members'[Metier] <> "Agriculteur"
&& 'Members'[Metier] <> "Fonctionnaire"
&& 'Members'[Metier] <> "Comptable"
&& 'Members'[Metier] <> BLANK ()
)
)
I do know that a common good practice is to refactor repeated values in a variable, but in this case, I don't think it would work since variables are a constant and in this case Metier changes for every line we're filtering.
When it comes to the submeasure, I just recently optimized it by precalculating some values in the source view.
SubMeasure :=
VAR lastPeriod = 'Time'[LastPeriod]
RETURN
CALCULATE (
[IsOK],
FILTER (
ALL ( Managing[PeriodLastSale], Managing[idPeriodEntry] ),
IF (
ISBLANK ( Managing[PeriodLastSale] ),
IF ( lastPeriod - Managing[idPeriodEntry] < 5, TRUE (), FALSE () ),
IF ( lastPeriod - Managing[PeriodLastSale] < 5, TRUE (), FALSE () )
)
)
)
Right now this parent measure takes a pretty long time to load, do you have an idea how I could optimize it ?
(The names are just mock names to convey the idea).
Kindly,
Nossair
Solved! Go to Solution.
It is not good practice to filter a whole table in your CALCULATE, so your first measure could be written like this.
MyMeasure :=
CALCULATE (
[Submeasure],
USERELATIONSHIP ( Sales[IdMember], 'Members'[IdMember] ),
NOT ( 'Members'[Metier] IN { "Chef", "Agriculteur", "Fonctionnaire", "Comptable", "" } )
)
Also, it is likely your submeasure may be causing the problem. Having IF (and nested IF, in your case) evaluated on each row of an iterator like FILTER will slow it down. You could likely rewrite it with AND or && instead of doing IFs.
Plus, your LastPeriod variable appears to be a column reference. Is that a measure?
Pat
It is not good practice to filter a whole table in your CALCULATE, so your first measure could be written like this.
MyMeasure :=
CALCULATE (
[Submeasure],
USERELATIONSHIP ( Sales[IdMember], 'Members'[IdMember] ),
NOT ( 'Members'[Metier] IN { "Chef", "Agriculteur", "Fonctionnaire", "Comptable", "" } )
)
Also, it is likely your submeasure may be causing the problem. Having IF (and nested IF, in your case) evaluated on each row of an iterator like FILTER will slow it down. You could likely rewrite it with AND or && instead of doing IFs.
Plus, your LastPeriod variable appears to be a column reference. Is that a measure?
Pat
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
63 | |
62 | |
52 | |
39 | |
24 |
User | Count |
---|---|
85 | |
57 | |
45 | |
43 | |
38 |