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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
jdecoste
New Member

How do you to get accurate daily status counts for table that only logs changes?

vinvehicle_fleet_statusvehicle_uptime_statusrecord_date
1G1FW6S00H4188325In fleetUptime4/26/22 0:38
1G1FW6S03H4146523In fleetUptime4/26/22 17:10
1G1FX6S00H4146123In fleetUptime4/27/22 22:39
1G1FW6S07H4183654In fleetDowntime4/27/22 22:39
1G1FW6S00H4187235In fleetDowntime4/27/22 22:39
1G1FZ6S05K4134756In fleetUptime4/28/22 17:25
1G1FW6S09H4181765In fleetUptime4/28/22 18:42
1G1FX6S00J4114944In fleetDowntime4/28/22 19:40
1G1FX6S00J4114054In fleetDowntime4/28/22 23:16

 

So I have a table set up like so, that logs a vehicles status. When a status changes (ie. uptime to downtime) a new row is inserted with the change reflected and the time. I am trying to get an output table that get and aggregate count of each status by day, which will look something like this.

DateIn fleetUptime
1/1/227671
1/2/227775
1/3/2277

74

 

So far, I have created a measure that will count a status:

count_in_fleet = CALCULATE(COUNTROWS(vehicle_logs),vehicle_logs[vehicle_fleet_status] = "In fleet")

 

And a summary table that shows that by day:

vehicle_log_aggregate =

SUMMARIZE(vehicle_logs,vehicle_logs[record_date].[Date],
"In Fleet", vehicle_logs[count_in_fleet])

 

However, since a status may not change over one day, the counts are innacurate. I need to somehow calculate what a VIN's status will be on x date by looking at the max(status) <= x date. However, I cant figure out how to put this together. Any help is greatly appreciated!

1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

HI @jdecoste,

You can take a look at the following calculated table expression to create a new table with aggregated records:

Table2 =
VAR summary =
    FILTER (
        SUMMARIZE (
            ALLSELECTED ( 'Table' ),
            [Date],
            [vin],
            "Infleet",
                COUNTX (
                    FILTER ( ALLSELECTED ( 'Table' ), [Date] = EARLIER ( 'Table'[Date] ) ),
                    [vin]
                ),
            "Status Changed", COUNTROWS ( VALUES ( 'Table'[vehicle_uptime_status] ) )
        ),
        [Status Changed] >= 2
    )
RETURN
    DISTINCT (
        SELECTCOLUMNS (
            summary,
            "Date", [Date],
            "Infleet", [Infleet],
            "Status Changed", [Status Changed]
        )
    )

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

1 REPLY 1
v-shex-msft
Community Support
Community Support

HI @jdecoste,

You can take a look at the following calculated table expression to create a new table with aggregated records:

Table2 =
VAR summary =
    FILTER (
        SUMMARIZE (
            ALLSELECTED ( 'Table' ),
            [Date],
            [vin],
            "Infleet",
                COUNTX (
                    FILTER ( ALLSELECTED ( 'Table' ), [Date] = EARLIER ( 'Table'[Date] ) ),
                    [vin]
                ),
            "Status Changed", COUNTROWS ( VALUES ( 'Table'[vehicle_uptime_status] ) )
        ),
        [Status Changed] >= 2
    )
RETURN
    DISTINCT (
        SELECTCOLUMNS (
            summary,
            "Date", [Date],
            "Infleet", [Infleet],
            "Status Changed", [Status Changed]
        )
    )

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
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!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.