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 Formula in Power BI

Hi All,

 

Im fairly new to Power BI and trying to build my own report/visual dashboard.

I have 1 dataset where i want to insert IF formula to compare if column A is greater than column B then return 1 else return 3.

Ultimately want to use the results  of this to create a traffic light using UNICHAR function.

 

However when doing the IF formula, it returns 3.10 where statement is true and blank where statement is false.

Power BI.PNG

 

 
2 ACCEPTED SOLUTIONS
speedramps
Super User
Super User

Hi majmsk 

 

Please consider one of these solutions and leave kudos

 

Method 1)

Add a conditional column in you M query

 

Method 2)

On the top menu bar>Click on Modelling>New measure and add these measures

 

Total last = SUM(YourTableName[Last])

Total current = SUM(YourTableName[Current])
Your flag = IF([Total current]>[Total last],1,3)

 

 

View solution in original post

harshnathani
Community Champion
Community Champion

Hi @Anonymous ,

 

You can try this measure.

 

 

Measure =

SWITCH(
TRUE(),
MAX('Table'[Last]) < MAX('Table'[Current]) , "3",

"1"

)

 

Regards,
Harsh Nathani

Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

View solution in original post

3 REPLIES 3
harshnathani
Community Champion
Community Champion

Hi @Anonymous ,

 

You can try this measure.

 

 

Measure =

SWITCH(
TRUE(),
MAX('Table'[Last]) < MAX('Table'[Current]) , "3",

"1"

)

 

Regards,
Harsh Nathani

Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

adhumal2
Helper III
Helper III

@AnonymousHi , Can you please send the sample file. It looks like some formatting issue

speedramps
Super User
Super User

Hi majmsk 

 

Please consider one of these solutions and leave kudos

 

Method 1)

Add a conditional column in you M query

 

Method 2)

On the top menu bar>Click on Modelling>New measure and add these measures

 

Total last = SUM(YourTableName[Last])

Total current = SUM(YourTableName[Current])
Your flag = IF([Total current]>[Total last],1,3)

 

 

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.