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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Munawar1881
Helper II
Helper II

IF Condition

Hi,

 

I have two dates 1. Shipment Date 2. Actual Shipment Date with Order Quantities. Now want to have IF condition where I can get the status if it is shipped Early (with number of days) , On Time or Delay (with number of days).

 

Thank you so much for help!

3 ACCEPTED SOLUTIONS
SpartaBI
Community Champion
Community Champion

@Munawar1881 write this calculated column:

 

 

Status = 
VAR _days = ABS(DATEDIFF('Table'[Shipment Date], 'Table'[Actual Shipment Date], DAY))
RETURN
SWITCH(
    TRUE(),
    'Table'[Shipment Date] < 'Table'[Actual Shipment Date], "Delay by " & _days & IF(_days = 1, " day",  " days"),
    'Table'[Shipment Date] > 'Table'[Actual Shipment Date], "Early by " & _days & IF(_days = 1, " day",  " days"),
    "On Time"
)

 


Here is a link to download the file with the solution:
IF Condition 2022-08-02.pbix


2022-05-19 17_30_22-Re_ Need help on DAX function with measure vs colu... - Microsoft Power BI Commu.png


Full-Logo11.png

SpartaBI_3-1652115470761.png   SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Showcase Report – Contoso By SpartaBI

View solution in original post

@Munawar1881 change the code to this:

 

 

Status = 
VAR _days = ABS(DATEDIFF('Table'[Shipment Date], 'Table'[Actual Shipment Date], DAY))
RETURN
SWITCH(
    TRUE(),
    'Table'[Actual Shipment Date] = BLANK(), "On Time",
    'Table'[Shipment Date] < 'Table'[Actual Shipment Date], "Delay by " & _days & IF(_days = 1, " day",  " days"),
    'Table'[Shipment Date] > 'Table'[Actual Shipment Date], "Early by " & _days & IF(_days = 1, " day",  " days"),
    "On Time"
)

 

 


2022-05-19 17_30_22-Re_ Need help on DAX function with measure vs colu... - Microsoft Power BI Commu.png


Full-Logo11.png

SpartaBI_3-1652115470761.png   SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Showcase Report – Contoso By SpartaBI

View solution in original post

@Munawar1881 here is a link to download the file with the solution:
IF Condition 2022-08-02.pbix

View solution in original post

8 REPLIES 8
SpartaBI
Community Champion
Community Champion

@Munawar1881 write this calculated column:

 

 

Status = 
VAR _days = ABS(DATEDIFF('Table'[Shipment Date], 'Table'[Actual Shipment Date], DAY))
RETURN
SWITCH(
    TRUE(),
    'Table'[Shipment Date] < 'Table'[Actual Shipment Date], "Delay by " & _days & IF(_days = 1, " day",  " days"),
    'Table'[Shipment Date] > 'Table'[Actual Shipment Date], "Early by " & _days & IF(_days = 1, " day",  " days"),
    "On Time"
)

 


Here is a link to download the file with the solution:
IF Condition 2022-08-02.pbix


2022-05-19 17_30_22-Re_ Need help on DAX function with measure vs colu... - Microsoft Power BI Commu.png


Full-Logo11.png

SpartaBI_3-1652115470761.png   SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Showcase Report – Contoso By SpartaBI

It works. Thak you so much for your help

my pleasure 🙂
Check out my showcase report - got some high level stuff there. Sure you will find there a lot of cool ideas. Please give it a thumbs up over there if you liked it 🙂
https://community.powerbi.com/t5/Data-Stories-Gallery/SpartaBI-Feat-Contoso-100K/td-p/2449543

If the oder is shipped in shipped date and actual shipment date is empty. normally It should be On Time but it shows delay. please guide me how can I solve it 

Hi,

 

Please help me!

 

If my purchase order quantity is equal to shipped quantity then 100% (Good)performance if purchase order quantity is less then shipped quantity then -% (Poor) Performance if purchase order quantity is higher than shipped quantity then +% (Best) performance.
within the expected shipment date. if date limit exceeds then delay days + PO Quantity = %Performance    

 

Thanks for help!

@Munawar1881 hey can you share maybe a sample data so I could copy paste it to PBIX and also just hard code the result you want to get and show why

@Munawar1881 here is a link to download the file with the solution:
IF Condition 2022-08-02.pbix

@Munawar1881 change the code to this:

 

 

Status = 
VAR _days = ABS(DATEDIFF('Table'[Shipment Date], 'Table'[Actual Shipment Date], DAY))
RETURN
SWITCH(
    TRUE(),
    'Table'[Actual Shipment Date] = BLANK(), "On Time",
    'Table'[Shipment Date] < 'Table'[Actual Shipment Date], "Delay by " & _days & IF(_days = 1, " day",  " days"),
    'Table'[Shipment Date] > 'Table'[Actual Shipment Date], "Early by " & _days & IF(_days = 1, " day",  " days"),
    "On Time"
)

 

 


2022-05-19 17_30_22-Re_ Need help on DAX function with measure vs colu... - Microsoft Power BI Commu.png


Full-Logo11.png

SpartaBI_3-1652115470761.png   SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Showcase Report – Contoso By SpartaBI

Helpful resources

Announcements
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! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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