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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
elif
Frequent Visitor

If statement doesn't work

Hello,

I have a problem with IF statement which is not working perfectly, do you have any idea why it is not working very well?

 

is grater = VAR maxtable1 = CALCULATE(MAX('Date'[Date]),USERELATIONSHIP('Product'[NPI End Date],'Date'[Date])) VAR maxtable2 = CALCULATE(MAX('Product'[NPI End Date])) RETURN IF ( maxtable2 >= maxtable1, 1, 0)
 
POS Type NEW = IF([is grater] = 1, "NPI", 'Product'[POS type])
 
elif_0-1645555053001.png

 

 There is an inactive relationship between the Product'[NPI End Date] and Date'[Date]
5 REPLIES 5
v-yalanwu-msft
Community Support
Community Support

Hi, @elif ;

Is your problem solved? If so, Would you mind accept the helpful replies as solutions? Then we could close the thread. More people who have the same requirement will find the solution quickly and benefit here. Thank you.

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-yalanwu-msft
Community Support
Community Support

Hi, @elif ;

Can you share  a simple data removing sensitive information, along with the results you want to output?

It makes it easier to give you a solution.

 

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@elif , If this is a column, this will not work

POS Type NEW = IF([is grater] = 1, "NPI", 'Product'[POS type])

 

It needs to be a measure

example

POS Type NEW = IF([is grater] = 1, "NPI", max('Product'[POS type]) )

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi @amitchandak 

 

I tried both of them but still not working. When I try your suggestion it gives me just 2 Product Type but has to be 5 like Core Product, Identity, NPI, Custom, outofscope, and the NPI calculation is wrong as well.

 

elif_0-1645631377674.png

 

@elif , This will not work as column,

You have create a measure as, you are using measure in calculation

POS Type NEW = IF([is grater] = 1, "NPI", max('Product'[POS type]) )

 

Not get this working as a Column, you need an independent table(assume POS Type)  with these two values.  using a group by NPI name you need create a new measure to get this working

 

 

new Measure
Sumx(filter(Values(Table[MPI Name]), [POS Type NEW] = max(POS Type[POS Type])), [measure])

 

 

refer this blog or video for steps

 

Dynamic Segmentation Bucketing Binning
https://community.powerbi.com/t5/Quick-Measures-Gallery/Dynamic-Segmentation-Bucketing-Binning/m-p/1...


Dynamic Segmentation, Bucketing or Binning: https://youtu.be/CuczXPj0N-k

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.