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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
selvaskm
Frequent Visitor

Count of latest status of each job

Hi All,

I need to count the latest status for each job from the below sample data. This below table is joined to calendar table through Date Column.

Job              Time                                                  Status

job101-03-2024 03:30 PMFail
Job101-03-2024 02:00 PMSuccess
Job101-03-2024 10:30 AMSuccess
Job201-03-2024 04:30 PMFail
job201-03-2024 10:30 AMSuccess
Job301-03-2024 06:30 PMSuccess
Job301-03-2024 04:30 PMFail
Job301-03-2024 12:30 PMFail
Job401-03-2024 09:30 AMFail
Job401-03-2024 10:30 PMStopped
Job401-03-2024 03:30 PMFail
Job401-03-2024 02:30 PMSuccess

Expected Output:
Fail - 2
Success - 1
Stopped - 1
As total 4 jobs are runned.

Please provide the measure for this scenario

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

 

Jihwan_Kim_0-1709361894885.png

 

 

INDEX function (DAX) - DAX | Microsoft Learn

 

expected result measure: =
VAR _t =
    ALL ( data )
VAR _count =
    COUNTROWS (
        FILTER (
            INDEX (
                1,
                _t,
                ORDERBY ( data[time], DESC ),
                ,
                PARTITIONBY ( data[job] ),
                MATCHBY ( data[job], data[time] )
            ),
            data[status] IN VALUES ( data[status] )
        )
    )
RETURN
    _count

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

View solution in original post

1 REPLY 1
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

 

Jihwan_Kim_0-1709361894885.png

 

 

INDEX function (DAX) - DAX | Microsoft Learn

 

expected result measure: =
VAR _t =
    ALL ( data )
VAR _count =
    COUNTROWS (
        FILTER (
            INDEX (
                1,
                _t,
                ORDERBY ( data[time], DESC ),
                ,
                PARTITIONBY ( data[job] ),
                MATCHBY ( data[job], data[time] )
            ),
            data[status] IN VALUES ( data[status] )
        )
    )
RETURN
    _count

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

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!

November Carousel

Fabric Community Update - November 2024

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

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.