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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Dax for populating Date by condition

Hi All,

 

i'm trying to write a DAX to calculate the Provision date of a packages that our customre have gotten.

Below is the Current Provision date :

Provision Date = CALCULATE( minx(overall,Overall[DateIn]) ,ALLEXCEPT ( Overall, Overall[CHASSIS],Overall[Package Name]),Overall[Category]="Provision")
 
CHASSISCategoryProvisionUtilisationClosing BalanceDateInPackage NameProvision Date
W17144Provision1140 11409/10/2015Tweet9/10/2015
W17144Utilisation -$380.-3809/10/2015Tweet9/10/2015
W17144Utilisation -$380.-38025/6/2016Tweet9/10/2015
W17144Utilisation -$380.-3801/4/2017Tweet9/10/2015
W17144Provision1026 102616/3/2018Tweet9/10/2015
W17144Utilisation -$380.-38020/3/2018Tweet9/10/2015
W17144Utilisation -$380.-38012/3/2019Tweet9/10/2015
W17144Utilisation -$380.-3804/3/2020Tweet9/10/2015
W17144Provision1026 10265/3/2021Tweet9/10/2015
W17144Utilisation -$380.-38015/3/2021Tweet9/10/2015

 

 

But i'm trying to dereive the below date instead:

THe provision date is based on the Category = Provision to derieve the date, any utilisation date that fall after the provision date will be using the Provision date until the next provision category was purchase then the provision date should be using re-populate. Any pro or guru able to provide their input?

 

Expected Result

CHASSISCategoryProvisionUtilisationClosing BalanceDateInPackage NameProvision Date
W17144Provision1140 11409/10/2015Tweet9/10/2015
W17144Utilisation -$380.-3809/10/2015Tweet9/10/2015
W17144Utilisation -$380.-38025/6/2016Tweet9/10/2015
W17144Utilisation -$380.-3801/4/2017Tweet9/10/2015
W17144Provision1026 102616/3/2018Tweet16/3/2018
W17144Utilisation -$380.-38020/3/2018Tweet16/3/2018
W17144Utilisation -$380.-38012/3/2019Tweet16/3/2018
W17144Utilisation -$380.-3804/3/2020Tweet16/3/2018
W17144Provision1026 10265/3/2021Tweet5/3/2021
W17144Utilisation -$380.-38015/3/2021Tweet5/3/2021
1 ACCEPTED SOLUTION
CNENFRNL
Community Champion
Community Champion

Provision Date = 
MAXX(
    FILTER(
        Overall,
        Overall[CHASSIS] = EARLIER( Overall[CHASSIS] )
            && Overall[DateIn] <= EARLIER( Overall[DateIn] )
            && Overall[Category] = "Provision"
    ),
    Overall[DateIn]
)

Screenshot 2021-11-25 211022.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

3 REPLIES 3
VahidDM
Super User
Super User

Hi @Anonymous 

 

Try this measure:

Provision Date = 
CALCULATE (
    MAX ( Overall[DateIn] ),
    FILTER (
        ALL ( Overall ),
        Overall[Provision] <> BLANK ()
            && Overall[DateIn] <= MAX ( Overall[DateIn] )
    )
)

 

Output:

VahidDM_0-1637879294835.png

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

CNENFRNL
Community Champion
Community Champion

Provision Date = 
MAXX(
    FILTER(
        Overall,
        Overall[CHASSIS] = EARLIER( Overall[CHASSIS] )
            && Overall[DateIn] <= EARLIER( Overall[DateIn] )
            && Overall[Category] = "Provision"
    ),
    Overall[DateIn]
)

Screenshot 2021-11-25 211022.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

amitchandak
Super User
Super User

@Anonymous , Try like. New measure

 


Provision Date = CALCULATE( minx(overall,Overall[DateIn]) ,filter (allselected (Overall), Overall[CHASSIS] = max(Overall[CHASSIS]) && Overall[Package Name] = max(Overall[Package Name]) && Overall[Category]="Provision"))

 

 

or

 


Provision Date = CALCULATE( minx(overall,Overall[DateIn]) ,filter (all(Overall), Overall[CHASSIS] = max(Overall[CHASSIS]) && Overall[Package Name] = max(Overall[Package Name]) && Overall[Category]="Provision"))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.