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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
MiloDi
Frequent Visitor

Return Max date based on multiple condition

Hello dear community

 

I can't get out of a worry.
I can express it, but I can't put it into words.

Here you have an exel chart.
On the left you have a small sample of data and on the right the expected result.

I have several of the same file numbers for different tasks.
The start date must always be the date corresponding to name, which contains AB.
The end date is a little more complex. I take the oldest date of the lines only if each line has the status TRUE if a line doesn't have the status True then it's empty.

Any ideas?

Thank you very much in advance

Files  

start_end_date.png

2 ACCEPTED SOLUTIONS
Daniel29195
Super User
Super User

hello @MiloDi 

output 

Daniel29195_0-1707928363258.png

 

 

measure 1 --  start date 

Start Date = 
var start_date = 
FILTER(
    Tableau1,
    Tableau1[Name] = "AB"
)
return 
MINX(start_date,Tableau1[Date])

 

 

measure 2 --  end date

End  Date = 
var count_all =  COUNTROWS(Tableau1)
var end_true = 
FILTER(
    Tableau1,
    Tableau1[Status] = TRUE()
)

 var count_true =  COUNTROWS(end_true)
var res = 
SWITCH(
    TRUE(),
    count_all <> count_true , blank(),
MAXX(end_true,[Date])
)
return  res

 

 

 

let me know if this works for you .

 

 

 

If my answer helped sort things out for you, i would appreciate a thumbs up 👍 and mark it as the solution
It makes a difference and might help someone else too. Thanks for spreading the good vibes! 🤠

 

View solution in original post

@MiloDi 

Daniel29195_0-1708024243825.png

 

modify the code to this : 

End  Date = 
var count_all =  calculate(COUNTROWS(Tableau1) , REMOVEFILTERS(Tableau1[Status]))
var end_true = 
FILTER(
    Tableau1,
    Tableau1[Status] = TRUE()
)

 var count_true =  COUNTROWS(end_true)
var res = 
SWITCH(
    TRUE(),
    count_all <> count_true , blank(),
MAXX(end_true,[Date])
)
return  res

 

 

 

let me know if this helps ....

 

 

 

If my answer helped sort things out for you, i would appreciate a thumbs up 👍 and mark it as the solution
It makes a difference and might help someone else too. Thanks for spreading the good vibes! 🤠

View solution in original post

4 REPLIES 4
Daniel29195
Super User
Super User

hello @MiloDi 

output 

Daniel29195_0-1707928363258.png

 

 

measure 1 --  start date 

Start Date = 
var start_date = 
FILTER(
    Tableau1,
    Tableau1[Name] = "AB"
)
return 
MINX(start_date,Tableau1[Date])

 

 

measure 2 --  end date

End  Date = 
var count_all =  COUNTROWS(Tableau1)
var end_true = 
FILTER(
    Tableau1,
    Tableau1[Status] = TRUE()
)

 var count_true =  COUNTROWS(end_true)
var res = 
SWITCH(
    TRUE(),
    count_all <> count_true , blank(),
MAXX(end_true,[Date])
)
return  res

 

 

 

let me know if this works for you .

 

 

 

If my answer helped sort things out for you, i would appreciate a thumbs up 👍 and mark it as the solution
It makes a difference and might help someone else too. Thanks for spreading the good vibes! 🤠

 

Good afternoon, Daniel29195, 

 

First thank you for your time and your answer. 

In my case its not working properly , I have date for Id who have one false statut. 

I join you the PBI, perhaps I do soemthing wrong. 

Can you guide me ? 

 

thank you in advance

 

https://we.tl/t-4iYlUSEeTh PBI.png

@MiloDi 

Daniel29195_0-1708024243825.png

 

modify the code to this : 

End  Date = 
var count_all =  calculate(COUNTROWS(Tableau1) , REMOVEFILTERS(Tableau1[Status]))
var end_true = 
FILTER(
    Tableau1,
    Tableau1[Status] = TRUE()
)

 var count_true =  COUNTROWS(end_true)
var res = 
SWITCH(
    TRUE(),
    count_all <> count_true , blank(),
MAXX(end_true,[Date])
)
return  res

 

 

 

let me know if this helps ....

 

 

 

If my answer helped sort things out for you, i would appreciate a thumbs up 👍 and mark it as the solution
It makes a difference and might help someone else too. Thanks for spreading the good vibes! 🤠

Hello @Daniel29195 

 

Thank you very much for your time. Its working fine sir. It's amazing. 

I understand your measure So I'm getting better at it too 😉

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.

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.