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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
EvaPBI
Frequent Visitor

DAX: Count the number of unique IDs with the last status per period

Hi everyone,

I thought this problem was easier to solve, but for some reason, I can't get the exact expected results and the solutions on the forum aren't exactly applicable.

 

Here is my main table :

IDPERIODDATESTATUS
12024-02-01 2024-02-01 A
12024-06-01 2024-06-20 A
22024-04-01 2024-04-14 B
22024-05-01 2024-05-12 A
22024-06-01 2024-06-10 A
22024-06-01 2024-06-18 B
32024-09-01 2024-09-03 B
32024-09-01 2024-09-07 A
42024-09-01 2024-09-28 B
52024-03-01 2024-03-11 B
52024-05-01 2024-05-16 A
52024-07-01 2024-07-21 B
62024-08-012024-08-08 B
62024-11-012024-11-17 A
72024-02-012024-02-28 B
72024-05-012024-05-05 B
72024-06-012024-06-21 B
72024-10-012024-10-27 A
82024-03-012024-03-15 B
82024-03-012024-03-22 A
92024-10-012024-10-22 B
92024-11-012024-11-09 B
82024-07-012024-07-25 B
102024-04-012024-04-07 A
102024-11-012024-11-14 B
102024-07-012024-07-26 A


With DAX, I want to count the number of unique IDs (based on the last status) per period (cumulatively) to create a graph showing the status changes.

Here are the expected results:

PERIODESTATUT ASTATUT B
2024-02-01 1 1
2024-03-01 2 2
2024-04-01 3 3
2024-05-01 5 1
2024-06-01 4 2
2024-07-01 2 4
2024-08-01 2 5
2024-09-01 3 6
2024-10-01 4 6
2024-11-01 4 6


For example, Period 2024-04-01 has
3 "A" Status (ID: 1, 8, 10) and
3 "B" Status (ID: 2, 5, 7).

I tried to create a first measure that identifies the lastest_status for the appropriate period (cumulatively) but the measure always identifies the last status (for period 2024-04-01, it would falsely classify ID 8 with a "B" Status). Note that it may not be the right way to start.

Thank you very much for any help or advice.
Best Regards,

 

Eva

1 ACCEPTED SOLUTION

6 REPLIES 6
EvaPBI
Frequent Visitor

Correct. No status change for ID 1.
The measures (STATUS_A_COUNT & STATUS_B_COUNT) should count the number of unique ID in each status per period.
As ID 1 Status didn't change, I expect it to be counted in the column STATUS_A for every period (see expected results table).
Thank you for the question, I didn't specify that 🙂

Like this?

 

lbendlin_2-1734041031090.png

 

 

 

Thank you very much !
The measure's behavior seems perfect. As I have a lot of IDs, the end goal is to show the number of status A and B per period. I try to apply a distinctcount on the measure and a filter on the status (=A and = B) but it didn't work. This is the expected result : 

EvaPBI_1-1734118303463.png

 

 

lbendlin_0-1734128637750.png

 

Very clever, works perfectly !

Thank you for your time.

lbendlin
Super User
Super User

I don't see any status changes for ID 1?

 

lbendlin_0-1734036328870.png

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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