Forum Discussion
Formula in measure not working as expected
Hi,
I have attached images and labelled 4 measures below and the resulting output. Measure 1 and 2 are related, and measure 3 and 4 are related. Measure 1 and 3 are similar and measure 2 and 4 are similar, but I am trying to determine why measure 4 is returning a blank when measure 2 works correctly. Does it have to do with filter context? All of them work except for Measure 4.
Measure 4 (Does Not Work):
Measure 3 (Works Correctly):
Measure 2 (Works Correctly):
Measure 1 (Works Correctly):
6 Replies
- AlexisOlson
Super User
Yes. It's likely due to filter context complications.
If you expect [Fake Dispatched Available MW] to be the same value for each row you are iterating over in the FILTER, then the solution is simple; calculate it once rather than for each row:
Price Setter (With Asset Removal) = VAR Fake = [Fake Dispatched Available MW] RETURN CALCULATE ( MIN ( MeritOrder[Price] ), FILTER ( MeritOrder, Fake <= MeritOrder[Cumulative Available MW] ) )If the measure should be dependent on the row context from the FILTER iterator, then things get more complicated.
- austinb97Regular Visitor
Thanks, however this does not appear to fix my issue with the BLANK getting returned. I just can't understand why Measure 2 works correctly and Measure 4 does not with essentially the same logic.
- AlexisOlson
Super User
What if you replace [Fake Dispatched Available MW] with the hardcoded value 8953? Do you get a non-blank or are you just filtering out the whole table?
Note: You are playing with fire having ALLSELECTED inside of a FILTER iterator. ALLSELECTED is really complicated to understand in such situations.
- v-luwang-msft
Community Support
Hi austinb97 ,
Try to adjust your measure4:
Price Setter(Wish Asset removal)= calculate(min(Meritorder[Price], Filter(all(MeritOrder),MeritOrder[Cumulative Available MW]>>=[Fake Dispatched Available MW]))Since I don't have your specific file, I use a similar model:
see the below:
Return(test2) is blank:(Incorrect)
return test:(correct)
When I add all to filter:(correct value)
refer :all
If question still not solved ,could you pls share your pbix file?
Don't forget to give thumbs up and accept this as a solution if it helped you!!!Best Regards
Lucien