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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
tkavitha911
Helper III
Helper III

Hi Team pls help this dax measure (day at port)

I have two tables: the first contains the columns MarketMax ETA Date, and Predicted Delivery Date; the second contains Capacity and Market. I need to calculate the difference between Max ETA Date and Predicted Delivery Date for each market. If the difference exceeds the capacity, the delivery should be scheduled for the next day

1 ACCEPTED SOLUTION
techies
Solution Sage
Solution Sage

Hi @tkavitha911 please try this calculated column

 

Adjusted Delivery Status =
VAR DiffDays =
    DATEDIFF(
        'ETA_Dates'[Predicted_Delivery_Date],
        'ETA_Dates'[Max_ETA_Date],
        DAY
    )
VAR CapacityDays =
    RELATED('Market_Capacity'[Capacity (Days)])

RETURN
IF(DiffDays > CapacityDays, "Schedule Next Day", "On Time")
― Power BI | Microsoft Fabric | PL-300 | DP-600 | Blog: medium.com/@cseprs_54978

View solution in original post

7 REPLIES 7
v-priyankata
Community Support
Community Support

Hi @tkavitha911 
I hope this information is helpful. Please let me know if you have any further questions or if you'd like to discuss this further. If this answers your question, please Accept it as a solution and give it a 'Kudos' so others can find it easily.
Thank you.

v-priyankata
Community Support
Community Support

Hi @tkavitha911 
I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank you.

v-priyankata
Community Support
Community Support

Hi @tkavitha911 

May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.

Thank you.

techies
Solution Sage
Solution Sage

Hi @tkavitha911 please try this calculated column

 

Adjusted Delivery Status =
VAR DiffDays =
    DATEDIFF(
        'ETA_Dates'[Predicted_Delivery_Date],
        'ETA_Dates'[Max_ETA_Date],
        DAY
    )
VAR CapacityDays =
    RELATED('Market_Capacity'[Capacity (Days)])

RETURN
IF(DiffDays > CapacityDays, "Schedule Next Day", "On Time")
― Power BI | Microsoft Fabric | PL-300 | DP-600 | Blog: medium.com/@cseprs_54978
Cookistador
Solution Sage
Solution Sage

Hi @tkavitha911 

 

Can you try to create a new column with following measure

 

Adjusted Delivery Date =
VAR predictedDeliveryDate = 'Table 1'[Predicted Delivery Date]
VAR maxEtaDate = 'Table 1'[Max ETA Date]
VAR marketCapacity = RELATED('Table 2'[Capacity])
VAR differenceInDays = DATEDIFF(predictedDeliveryDate, maxEtaDate, DAY)

RETURN
IF(
differenceInDays > marketCapacity,
predictedDeliveryDate + 1, 
predictedDeliveryDate 
)

 

If it is not what you are trying to achieve, can you give us more details like an excel sample of what you are trying to achieve ?

Not working pls fix this dax im getting The following syntax error occurred during parsing: Invalid token, Line 4, Offset 2,  .

Adjusted Delivery Status =
VAR currentDate = SELECTEDVALUE('DateTable'[Date])
VAR deliveriesOnDate =
    FILTER(
        'Inbound_Query',
        'Inbound_Query'[Max of ETA] = currentDate
    )
VAR result =
    ADDCOLUMNS(
        deliveriesOnDate,
        "DiffDays", DATEDIFF('Inbound_Query'[Predicted_Delivery_Date], 'Inbound_Query'[Max of ETA], DAY),
        "Capacity", RELATED('Inbound_Query'[Capacity])
    )
VAR flagged =
    FILTER(
        result,
        [DiffDays] > [Capacity]
    )
RETURN
IF(COUNTROWS(flagged) > 0, "Schedule Next Day", "On Time")

This is the daily data at the port, but since the dates are not continuous, I created a separate dates table. I need help writing a DAX measure to calculate the difference between the Max ETA Date and the Predicted Delivery Date for each market. If the difference exceeds the capacity, the delivery should be scheduled for the next day.

The expression will be: (Max ETA Date - Predicted Delivery Date). If the difference exceeds the available capacity, the remaining quantity should be carried over to the next day, and this cycle should continue until all deliveries are scheduled.

MarketMax of etaPredicted_Delivery_DateMax of etaCapacity
Japan01-02-2024'04-01-190012-10-20242
Japan01-02-2024'04-01-190010-03-20252
Philippines01-02-2024'04-01-190010-04-20259
Vietnam01-02-2024'04-01-190004-10-20242
Taiwan01-02-2024'04-01-190019-04-20256
Thailand01-02-2024'04-01-190001-03-20257
Australia01-02-2024'04-01-190008-02-20256
China01-02-2024'04-01-190030-03-20258
Shenzhen01-02-2024'04-01-190023-03-20254
Korea01-02-2024'04-01-190029-11-202410
Vietnam01-02-2024'04-01-190021-03-20252
China01-02-2024'04-01-190021-03-20258
Japan02-02-202404-01-190021-03-20252
Japan03-02-202404-01-190021-03-20252
Philippines04-02-202404-01-190021-03-20259
Vietnam05-02-202404-01-190021-03-20252
Taiwan02-02-202404-01-190004-04-20256
Thailand03-02-202404-01-190004-04-20257
Australia04-02-202404-01-190004-04-20256
China05-02-202404-01-190030-03-20258
Shenzhen06-02-202404-01-190004-04-20254
Korea07-02-202404-01-190003-05-202510
Vietnam08-02-202404-01-190021-08-20242
China09-02-202404-01-190021-08-20248

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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