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
Polar_A
Helper I
Helper I

Dax to populate next delivery date.

Hi I need a bit of help with one of my DAx measures.

I'm trying to generate the next delivery date to show after today.

My current measure is

 

Next Delivery Date =
CALCULATE(
    MIN('Delivery Schedule'[clu_deliverydate.1]),
    'Delivery Schedule'[clu_deliverydate.1] > TODAY(),
    ALLEXCEPT(Patients,Patients[Patient ID])
).
 
This removes all of the past delivery dates but I want to limit this one to only show the next one. For example this will show delivery 03 and only Delivery 03

Polar_A_0-1720604771402.png


KR,

7 REPLIES 7
v-kaiyue-msft
Community Support
Community Support

Hi @Polar_A ,

 

Thanks for the reply from @bhanu_gautam  and @Shaurya , please allow me to provide another insight: 

 

You can try this.

Next Delivery Date =
CALCULATE(
    MINX(
        TOPN(
            1,
            FILTER(
                'Delivery Schedule',
                'Delivery Schedule'[clu_deliverydate.1] > TODAY()
            ),
            'Delivery Schedule'[clu_deliverydate.1],
            ASC
        ),
        'Delivery Schedule'[clu_deliverydate.1]
    ),
    ALLEXCEPT(Patients, Patients[Patient ID])
)

 

If this doesn't solve your problem. Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data. We can better understand the problem and help you.

 

Best Regards,

Clara Gong

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Hi @v-kaiyue-msft@Shaurya@bhanu_gautam.

Thank you all this was the best solution for me with the measure NDD showing as Next Day Delivery.

I am now trying to group it by the prescription number, so that with prescription number 3001067 shows delivery 02 and not delivery 03; Prescription Number 3001034 shows Delivery 03 and not Delivery 04, 05, 06, etc..

Essentially I want to next delivery based on the prescription number.

KR

 

Polar_A_2-1720694869233.png

 

Hi @Polar_A ,

 

Create measure.

Next Delivery Date =
VAR _date =
    CALCULATE (
        MIN ( 'Delivery Schedule'[clu_deliverydate.1] ),
        'Delivery Schedule'[clu_deliverydate.1] > TODAY (),
        FILTER (
            'Patients',
            'Patients'[Prescription] = MAX ( 'Patients'[Prescription] )
        )
    )
RETURN
    IF ( MAX ( 'Delivery Schedule'[clu_deliverydate.1] ) = _date, 1, 0 )

 

Then filter the data with Next Delivery Date of 1 in the filter.

vkaiyuemsft_0-1720777910298.png

 

If your Current Period does not refer to this, please clarify in a follow-up reply.

 

Best Regards,

Clara Gong

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-kaiyue-msft,

Thank you.

I tried this and it is still showing everything rather than just the one delivery which i would want to be delivery 04.

Polar_A_0-1721130578623.png

 

Shaurya
Memorable Member
Memorable Member

Hi @Polar_A,

 

Try using this:

 

Next Delivery Date = 
CALCULATE(
    MIN('Delivery Schedule'[clu_deliverydate.1]),
    FILTER(
        ALLEXCEPT(Patients, Patients[Patient ID]),
        'Delivery Schedule'[clu_deliverydate.1] > TODAY()
    )
)

 

Works for you? Mark this post as a solution if it does!
Check out this blog of mine: How to Export Telemetry Data from Azure IoT Central into Power BI  

bhanu_gautam
Super User
Super User

@Polar_A , Try using below measure

 

Next Delivery Date =
CALCULATE(
MIN('Delivery Schedule'[clu_deliverydate.1]),
FILTER(
ALLEXCEPT('Delivery Schedule', 'Delivery Schedule'[Patient ID]),
'Delivery Schedule'[clu_deliverydate.1] > TODAY()
)
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Hi @bhanu_gautam,

Its not working as the Patients ID is in a different table. It is in the Patients Stable and not the delivery Schedule table.

KR

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.