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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
Anonymous
Not applicable

Card that shows the Earliest time on the latest date

My report has a date/time field that shows the date/time of the first part confirmed for a shift.

I need to display a date/time in a Card that is the earliest time from the most recent date.

My data pulls from a dataflow several times a day and I'm trying to show the most recent data. However for this card I'm trying to show, essentially, at what time did we start making parts for a particular shift.

What I'm currently doing is: I have two card per shift - Earliest confirmation and latest confirmation (each that are flagged in another column as a "first piece confirmation"). I have the field set for the earliest one to show the earliest and the latest to show the latest. 
My data for this page is filtered for the relative 2 days, including today.
The issue with this approach is: that the earlierst may show yesterday and the latest may show today (if data exists for today).
What I want is: If there is data for today to show the earliest and latest for it. If not, then show the earliest and latest for yesterday.

 

[FYI I am inable to share my report or data due to company policy.]

 

Edit: My data might take one of two forms:

Saw25_0-1689703233353.png

 

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

Hi @Anonymous ,

 

You want two card visuals, one that shows today's latest time and one that shows today's earliest time. If there is no Today in the table, yesterday's is displayed.

Here're two measure for your reference. You can replace DATE(2023,7,12) with TODAY()

the latest time for recent date = var _today=DATE(2023,7,12)
var _date=MAX('Have data tody'[Date])
var _todaymax=MAXX(FILTER(ALLSELECTED('Have data tody'),[Date]=_today),[Date/Time])
var _yesterdaymax=MAXX(FILTER(ALLSELECTED('Have data tody'),[Date]=_today-1),[Date/Time])
var _if=IF(COUNTROWS(FILTER(ALLSELECTED('Have data tody'),[Date]=_today))>=1,_todaymax)
return _if
the earliest time for recent date = var _today=DATE(2023,7,12)
var _date=MAX('Have data tody'[Date])
var _todaymin=MINX(FILTER(ALLSELECTED('Have data tody'),[Date]=_today),[Date/Time])
var _yesterdaymin=MINX(FILTER(ALLSELECTED('Have data tody'),[Date]=_today-1),[Date/Time])
var _if=IF(COUNTROWS(FILTER(ALLSELECTED('Have data tody'),[Date]=_today))>=1,_todaymin,_yesterdaymin)
return _if

 

vstephenmsft_0-1689835031198.png

                                                                                                                                                         

Best Regards,

Stephen Tao

 

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

View solution in original post

Anonymous
Not applicable

Thank you. I managed to come to almost the same solution. My code is a bit different but it seems to work well. Thank you.

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @Anonymous ,

 

You want two card visuals, one that shows today's latest time and one that shows today's earliest time. If there is no Today in the table, yesterday's is displayed.

Here're two measure for your reference. You can replace DATE(2023,7,12) with TODAY()

the latest time for recent date = var _today=DATE(2023,7,12)
var _date=MAX('Have data tody'[Date])
var _todaymax=MAXX(FILTER(ALLSELECTED('Have data tody'),[Date]=_today),[Date/Time])
var _yesterdaymax=MAXX(FILTER(ALLSELECTED('Have data tody'),[Date]=_today-1),[Date/Time])
var _if=IF(COUNTROWS(FILTER(ALLSELECTED('Have data tody'),[Date]=_today))>=1,_todaymax)
return _if
the earliest time for recent date = var _today=DATE(2023,7,12)
var _date=MAX('Have data tody'[Date])
var _todaymin=MINX(FILTER(ALLSELECTED('Have data tody'),[Date]=_today),[Date/Time])
var _yesterdaymin=MINX(FILTER(ALLSELECTED('Have data tody'),[Date]=_today-1),[Date/Time])
var _if=IF(COUNTROWS(FILTER(ALLSELECTED('Have data tody'),[Date]=_today))>=1,_todaymin,_yesterdaymin)
return _if

 

vstephenmsft_0-1689835031198.png

                                                                                                                                                         

Best Regards,

Stephen Tao

 

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

Anonymous
Not applicable

Thank you. I managed to come to almost the same solution. My code is a bit different but it seems to work well. Thank you.

VilmarSch
Post Partisan
Post Partisan

Pode enviar uma amostra dos seus dados com informações ficticias, e exemplo do que deseja?

Anonymous
Not applicable

I updated my post to include a sample.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 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.