Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
DorisCMoore
Frequent Visitor

How to dynamically modify a Measure result based on a specific value?

Hello,

 

I'm trying to create a Measure, which calculation should be dynamically impacted based on a column value.

 

To illustrate, here's the "default" mesure I'm using:

Measure = CALCULATE(sum(AllWorkItems[Effort]),AllWorkItems[State]="Done")

 
Simply put, if my State column shows "Done" value, then I want to calculate the Sum for my Effort column.
 
On top of that, I have a [WI] column, and I would like the result of this measure to vary according to the WI value (add 100 to the result if WI is a Bug, or just keep the result as it is for any other value)
 
Code equivalent would be something like that:
 
If State = "Done" then
If WI = "Bug" then
Sum(Effort) + 100
else
Sum(Effort)
End if
end if
 
So far my workaround was to duplicate the measure.
Is it possible to achieve the same result through one single measure?
 
Thank you,
Doris
1 ACCEPTED SOLUTION
andhiii079845
Super User
Super User

In which context do you want your measure? Can you please make this more clear for me, please?
You can try this:

Measure = IF(MAX('Table'[Wi])="Bug",CALCULATE(sum('Table'[Effort]),'Table'[State]="Done")+100,CALCULATE(sum('Table'[Effort]),'Table'[State]="Done"))
 
Be aware of the measure you use sum instead of sumx. 




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

5 REPLIES 5
andhiii079845
Super User
Super User

In which context do you want your measure? Can you please make this more clear for me, please?
You can try this:

Measure = IF(MAX('Table'[Wi])="Bug",CALCULATE(sum('Table'[Effort]),'Table'[State]="Done")+100,CALCULATE(sum('Table'[Effort]),'Table'[State]="Done"))
 
Be aware of the measure you use sum instead of sumx. 




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Works like a charm, thank you so much!! 😊

andhiii079845
Super User
Super User

Do you have some example data? 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




andhiii079845
Super User
Super User

Use a VAR and RETURN construct:

Mymeasure = 

Var _firstmeasure = CALCULATE(sum(AllWorkItems[Effort]),AllWorkItems[State]="Done")

Var *The WI BUG* 

Return iif() 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thank you for the proposition but var WIbug = AllWorkItems[WI] = "Bug" is probably what bothers me since the begining. As WI is a string value, I'm always gettig a "cannot find name" kind of error.

 

Maybe this is how I should have put the question: how can we manipulate strings in a measure?

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.