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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Julian_HH
Regular Visitor

Calculating date difference from today to determine Status

Hi all,

I have a dataset where I need to calculate and highlight jobs that has not started and has the below criteria:

- They are within 2 to 3 weeks from the [Expected Delivery Date] (EDD).
- They are within 1 week from the EDD, or doesn't have another date entered [HandIn Date]
- There are less than 80% of the [Ordered Quantity] in the [Warehouse Stock], on or after the EDD

I have tried creating a Calculated Column using DATEDIFF to subtract the EDD and TODAY() to get a number then use that to filter out my results, but no luck.

What might be other ways of getting around to do the above? I am relatively new to PowerBI, and would like to learn more about the tool. Thanks!

Julian

1 ACCEPTED SOLUTION

Hi @Julian_HH,

 

If I understand you correctly, you should be able to use the formulas below to add three calculate columns in your table to indicate it is Alert 1, Alert 2, and Alert 3. Then use the the three calculate columns as Slicers on your report. Smiley Happy

IsAlert1 = 
IF (
    Main[Expected Delivery Date] - Main[Work Start Date 1]
        > 21
        && Main[Expected Delivery Date] - Main[Work Start Date 2]
        > 21,
    1,
    0
)
IsAlert2 = 
IF (
    Main[Expected Delivery Date] - Main[Work Start Date 1]
        > 7
        && Main[Expected Delivery Date] - Main[Work Start Date 2]
        > 7
        && Main[Expected Delivery Date] - Main[HandIn Date 1]
        > 7
        && Main[Expected Delivery Date] - Main[HandIn Date 2]
        > 7,
    1,
    0
)
IsAlert3 =
IF (
    ( Main[Packed Stock] + Main[Warehouse Stock] )
        < Main[Order Quantity] * 0.8,
    1,
    0
)

r2.PNG

 

Here is modified pbix file for your reference. Smiley Happy

 

Regards

View solution in original post

4 REPLIES 4
v-ljerr-msft
Microsoft Employee
Microsoft Employee

Hi @Julian_HH,

 

Could you post your table structures with some sample/dummy data and your expected result, so that we can better assist on this issue? It's better to share a sample pbix file. You can upload it to OneDrive or Dropbox and post the link here. Do mask sensitive data before uploading. Smiley Happy

 

Regards

Hi @v-ljerr-msft,

 

Thank you for replying, here's a link to the .pbix file. I have tried filtering out non-related columns and data, hope I didn't miss anything.

 

To clarify, what I would like to do is to mainly work from the "Expected Delivery Date" & "Work Start Date". The conditions I want to highlight:

 

- If there is no "Work Start Date" 3 weeks from the "Expected Delivery Date", then mark that as Alert 1.

If there is no "Work Start Date" or "HandIn Date" 1 week from the "Expected Delivery Date", then mark that as Alert 2.

- If there are less than 80% of the "Ordered Quantity" in the "Packed Stock" & "Warehouse Stock" on or after the "Expected Delivery Date", then mark that as Alert 3.

 

I would like the result to be in a table form, so that I could use conditional formatting based on the Alerts. 

 

Sorry if I'm not clear enough! Thanks!

 

Julian

 

 

Hi @Julian_HH,

 

If I understand you correctly, you should be able to use the formulas below to add three calculate columns in your table to indicate it is Alert 1, Alert 2, and Alert 3. Then use the the three calculate columns as Slicers on your report. Smiley Happy

IsAlert1 = 
IF (
    Main[Expected Delivery Date] - Main[Work Start Date 1]
        > 21
        && Main[Expected Delivery Date] - Main[Work Start Date 2]
        > 21,
    1,
    0
)
IsAlert2 = 
IF (
    Main[Expected Delivery Date] - Main[Work Start Date 1]
        > 7
        && Main[Expected Delivery Date] - Main[Work Start Date 2]
        > 7
        && Main[Expected Delivery Date] - Main[HandIn Date 1]
        > 7
        && Main[Expected Delivery Date] - Main[HandIn Date 2]
        > 7,
    1,
    0
)
IsAlert3 =
IF (
    ( Main[Packed Stock] + Main[Warehouse Stock] )
        < Main[Order Quantity] * 0.8,
    1,
    0
)

r2.PNG

 

Here is modified pbix file for your reference. Smiley Happy

 

Regards

Hi @v-ljerr-msft,

 

This is great! Thanks a lot! Smiley Very Happy

 

 

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.