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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Saw25
New Member

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
v-stephen-msft
Community Support
Community Support

Hi @Saw25 ,

 

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

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
v-stephen-msft
Community Support
Community Support

Hi @Saw25 ,

 

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.           

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?

I updated my post to include a sample.

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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