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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
o59393
Post Prodigy
Post Prodigy

Return earliest date subject to some conditions

Hi all

 

I want to know if it's possible with Power BI to have a measure that returns me a the earliest date where the hours is different than zero .

 

For example I have this table:

 

o59393_1-1696651520273.png

 

The desired result would be:

 

o59393_2-1696651542939.png

 

I tried the following dax:

 

Most Recent Date With Hours <> 0 = 

MAXX(
    FILTER(
        'Hours by line - Official',
        'Hours by line - Official'[Upcoming New Line? (Yes/No)] = "Yes" 
&& 'Hours by line - Official'[Available Production Hours] <> 0
    ),
    'Hours by line - Official'[Date]
)

 

However the result with the measure above is giving me December 2024 only.

 

Any idea how could I get it right?

 

Thanks.

1 ACCEPTED SOLUTION

MinDate = 
VAR _t = MAX( 'Hours by line - Official'[Manufacturing plant] )
VAR _tbl =
    FILTER(
        ALL( 'Hours by line - Official' ),
        'Hours by line - Official'[Manufacturing plant] = _t
            && 'Hours by line - Official'[Upcoming New Line? (Yes/No)]
            = "Yes"
            && 'Hours by line - Official'[Available Production Hours] <> 0
    )
RETURN
   
           CALCULATE( MIN( 'Hours by line - Official'[Date] ), _tbl )

View solution in original post

4 REPLIES 4
Ahmedx
Super User
Super User

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

Return earliest date.pbix

Hi @Ahmedx 

 

Thanks a lot. Could it be possible to have the dax measure returning the earliest date instead of a 1 or 0? 

 

Thanks!

 

 

MinDate = 
VAR _t = MAX( 'Hours by line - Official'[Manufacturing plant] )
VAR _tbl =
    FILTER(
        ALL( 'Hours by line - Official' ),
        'Hours by line - Official'[Manufacturing plant] = _t
            && 'Hours by line - Official'[Upcoming New Line? (Yes/No)]
            = "Yes"
            && 'Hours by line - Official'[Available Production Hours] <> 0
    )
RETURN
   
           CALCULATE( MIN( 'Hours by line - Official'[Date] ), _tbl )

Thank you very much @Ahmedx  🙂 

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

AugPowerBI_Carousel

Power BI Monthly Update - August 2024

Check out the August 2024 Power BI update to learn about new features.

August Carousel

Fabric Community Update - August 2024

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