The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
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
job1 | 01-03-2024 03:30 PM | Fail |
Job1 | 01-03-2024 02:00 PM | Success |
Job1 | 01-03-2024 10:30 AM | Success |
Job2 | 01-03-2024 04:30 PM | Fail |
job2 | 01-03-2024 10:30 AM | Success |
Job3 | 01-03-2024 06:30 PM | Success |
Job3 | 01-03-2024 04:30 PM | Fail |
Job3 | 01-03-2024 12:30 PM | Fail |
Job4 | 01-03-2024 09:30 AM | Fail |
Job4 | 01-03-2024 10:30 PM | Stopped |
Job4 | 01-03-2024 03:30 PM | Fail |
Job4 | 01-03-2024 02:30 PM | Success |
Expected Output:
Fail - 2
Success - 1
Stopped - 1
As total 4 jobs are runned.
Please provide the measure for this scenario
Solved! Go to Solution.
Hi,
Please check the below picture and the attached pbix file.
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.
Hi,
Please check the below picture and the attached pbix file.
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.
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the June 2024 Power BI update to learn about new features.
User | Count |
---|---|
40 | |
33 | |
20 | |
16 | |
15 |
User | Count |
---|---|
55 | |
50 | |
36 | |
33 | |
28 |