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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

IF Statement Not Working

Hey BI Community,

 

It has been a while since I have been on for some help. I am looking for some today though. I have built an IF Statment to add text indicators in one column related to whole number values in another. What I am trying to do is label certain groups of numbers based on certain criteria. However, when I look at the table for some reason it comes out incorrectly, with numbers not fitting appropriately. I will include the table image below and also the associated functions. 

 

POForecastLabel.jpg

 

 

So in the image, there is a column title DayDiff_OpenPO this column takes the DateDiff of Delivery Date & Confirmed Delivery Date and returns a value. Then, based on that value the column "PO Forecast Label" should say Early, On-Time, or Late depending on the value. 

 

Date diff function: 

 

DayDiff_OpenPO = DATEDIFF(OnTimeDelivery[Delivery Date],OnTimeDelivery[ConfirmedDeliveryDate],DAY)
 
IF Statement: 
 
PO Forecast Label = IF(OnTimeDelivery[DayDiff_OpenPO] <= -5 , "Expected Early", IF(AND(OnTimeDelivery[DayDiff_OpenPO] >= -4, OnTimeDelivery[DayDiff_Requested] <= 3), "Expected On-Time", IF(OnTimeDelivery[DayDiff_OpenPO] >= 4, "Expected Late", BLANK())))
 
I am seriously unsure why it is coming out this way as I have not had this problem before. Any help would be greatly appreciated!
2 REPLIES 2
v-lili6-msft
Community Support
Community Support

hi  @Anonymous 

It seems that [PO Forecast Label] is a new column

For your case, you should create a new measure

 

PO Forecast Label = IF(SUM(OnTimeDelivery[DayDiff_OpenPO]) <= -5 , "Expected Early", IF(AND(SUM(OnTimeDelivery[DayDiff_OpenPO]) >= -4, SUM(OnTimeDelivery[DayDiff_Requested]) <= 3), "Expected On-Time", IF(SUM(OnTimeDelivery[DayDiff_OpenPO]) >= 4, "Expected Late", BLANK())))

 

iF not your case, please share your sample pbix file for us have a test, that will be a great help.

 

Regards,

Lin

Community Support Team _ Lin
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

@Anonymous , Seem correct hope both are columns ??

You can try line -

PO Forecast Label =
switch (True(),
OnTimeDelivery[DayDiff_OpenPO] <= -5 , "Expected Early",
OnTimeDelivery[DayDiff_OpenPO] >= -4 && OnTimeDelivery[DayDiff_Requested] <= 3, "Expected On-Time",
OnTimeDelivery[DayDiff_OpenPO] >= 4, "Expected Late"
,blank())

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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