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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register 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
Anonymous
Not applicable

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 @Anonymous, @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

 

Anonymous
Not applicable

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 @Anonymous,

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
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.