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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
KH_Mike
Helper III
Helper III

How to use "If" in "New Measure" to check the another field?

Hello All,

 

I am trying to use the "New Measure" to hardcode the "Target" number. However, I am not sure how to check the data column in order to return the correct "Target".

 

My formula is like this but it won't work.  

If ( Data[Type] = "A" , 100 , If ( Data[Type] = "B" = 200 , If ( Data[Type] = "C" = 300 , 0 )))

3 REPLIES 3
KH_Mike
Helper III
Helper III

Hi All,

 

I try to use max on for each Data[Type] and it do return the result I want. However, why the "Total" is not the sum by all those figure? Now, the "Total" is 300 .......

@KH_Mike , Try one of the two ways.

 

Sumx(Data,
Switch ( True(),
Data[Type] = "A" , 100 ,
Data[Type] = "B" = 200 ,
Data[Type] = "C" = 300 , 0 ))

 

Sumx(Values(Max(Data[Type])), calculate(
Switch ( True(),
Max(Data[Type]) = "A" , 100 ,
Max(Data[Type])= "B" = 200 ,
Max(Data[Type])= "C" = 300 , 0 ) ) )

Hi @amitchandak 

 

I tried to use your method but it will come out few thousand for A and few thousand for B. Is it because I have many serval A and B records?

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.