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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
DemiHaung
Frequent Visitor

DAX Measure Base on Column value

Hi All

 

I will appreciate your help as I'm trying to figure out my roadblock  in power bi, here is the scenario

I'm trying to create a measure base on the value on the field, the table have already  3 measures but I want to create a 4th but the formula is different based on the column value.

 

I'm trying to invoke the if but it didn't detect the field name since its a calculated measure.

 

 

Product Measure 1Measure 2Measure 3Measure 4
A100150300if Product = A then Measure 1 + Measure 3
                  else measure 1 + Measure 2 + Measure 3
B100150300if Product = A then Measure 1 + Measure 3
                  else measure 1 + Measure 2 + Measure 4
C100150300if Product = A then Measure 1 + Measure 3
                  else measure 1 + Measure 2 + Measure 5

 

 

Thank you

 

 

2 ACCEPTED SOLUTIONS
VijayP
Super User
Super User

@DemiHaung 
IF(Selectedvalue(Tablename[Product])= "A", your result , your other result

you can't pick the column name directly in a measure so this is the approach! Share your Kudos




Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
MY Blog || My YouTube Channel || Connect with me on Linkedin || My Latest Data Story - Ageing Analysis

Proud to be a Super User!


View solution in original post

tej147
Frequent Visitor

Hi DemiHaung, Try this

 

Measure 4 =
VAR SelectedProduct = SELECTEDVALUE(Table[Product])
RETURN
IF(
SelectedProduct = "A", [Measure1]+[Measure2]+[Measure3],
BLANK()
)

 

If found helpful mark as a solution or give Kudos for efforts. Thanks!

View solution in original post

3 REPLIES 3
tej147
Frequent Visitor

Hi DemiHaung, Try this

 

Measure 4 =
VAR SelectedProduct = SELECTEDVALUE(Table[Product])
RETURN
IF(
SelectedProduct = "A", [Measure1]+[Measure2]+[Measure3],
BLANK()
)

 

If found helpful mark as a solution or give Kudos for efforts. Thanks!

thank you it works, I never thought I can use the selectedvalue this way.

 

 

VijayP
Super User
Super User

@DemiHaung 
IF(Selectedvalue(Tablename[Product])= "A", your result , your other result

you can't pick the column name directly in a measure so this is the approach! Share your Kudos




Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
MY Blog || My YouTube Channel || Connect with me on Linkedin || My Latest Data Story - Ageing Analysis

Proud to be a Super User!


Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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