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

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.

Reply
Anonymous
Not applicable

"If" Statement in Calcualted Column

Hello! I'm trying to create a calulated column in a PBI desktop report utilizing an "If" Statement in order to return a calulated value. I've tried cearting a custom and calculated column so far and have also tried creating DAX expressions with and without a "SWITCH" statement but I can't seem to get anything to work (an example of such a statement is below). Essentially what I'm trying to accomplish is that if my BINGO_AUTOMATION[CURRENT_POD] column is less than my BINGO_AUTOMATION[TARGET_POD] column I want it to caluclate the difference between the two in order to return a engative value.
 
Column 1 = SWITCH (if (BINGO_AUTOMATION[CURRENT_POD] < BINGO_AUTOMATION[TARGET_POD]) then (BINGO_AUTOMATION[CURRENT_POD] - BINGO_AUTOMATION[TARGET_POD]) else "0")
 
Thanks in advance for your help!
1 ACCEPTED SOLUTION
PattemManohar
Community Champion
Community Champion

@Anonymous You no need to have SWITCH here... Also your IF syntax is not correct.

 

Please try this... 

 

if (BINGO_AUTOMATION[CURRENT_POD] < BINGO_AUTOMATION[TARGET_POD],BINGO_AUTOMATION[CURRENT_POD] - BINGO_AUTOMATION[TARGET_POD]
,0)




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

Proud to be a PBI Community Champion




View solution in original post

4 REPLIES 4
PattemManohar
Community Champion
Community Champion

@Anonymous You no need to have SWITCH here... Also your IF syntax is not correct.

 

Please try this... 

 

if (BINGO_AUTOMATION[CURRENT_POD] < BINGO_AUTOMATION[TARGET_POD],BINGO_AUTOMATION[CURRENT_POD] - BINGO_AUTOMATION[TARGET_POD]
,0)




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

Proud to be a PBI Community Champion




Anonymous
Not applicable

actually, upon further investigation - the formula doesn't filter out instances where the Current >= Target. it's just calculating the measure for every row as opposed to only those where Current < Target.

 

Anonymous
Not applicable

This worked! Thank you so much!

hthota
Resolver III
Resolver III

Rewrite the Column as given below.

Column 1 = SWITCH (if (BINGO_AUTOMATION[CURRENT_POD] < BINGO_AUTOMATION[TARGET_POD),(BINGO_AUTOMATION[CURRENT_POD] - BINGO_AUTOMATION[TARGET_POD]),Null)

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.