Forum Discussion
How to get a correct count when statuses change
- 4 years ago
Hi Anonymous - Thank you for your response. After looking at it some more, I was able to find a workable solution. As you stated above, the calculated columns were returning a 1 for what ever Status was in the Status column, for each Unique ID. But when the status changes, I needed to have the old status show a 0, with the new status showing 1.
The solution I found was to create a calculated column to show the most recent date for a status:
Newest Status Date =MAXX (FILTER (ALL ( Table ),Table[Unique ID] = EARLIER ( Table[Unique ID] )),Table[Date From])And then adjusted the Research Count and Cultivation Count column DAX to:Research Count =IF (Table[Status] = "Research"&& Table[Date From] = Table[Newest Status Date],1,0)This allows the table to show 1 current status count when there is a change.Unique ID Status Date From Previous Status Previous Date Research Count Cultivation Count Newest Status Date 1 Research 3/28/2022 0 0 3/30/2022 1 Cultivation 3/30/2022 Research 3/28/2022 0 1 3/30/2022 Thanks again for your help.
-Dereck
Hi dostdahl
From your DAX you can see , if Status = "Research" then return 1 , so it return 1 in Research Count . From the data and formulas you have provided so far, there is nothing wrong with this .
Could you provide your pbix file or more detailed data or formulas to illustrate your problem ?
Best Regards,
Community Support Team _ Ailsa Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Anonymous - Thank you for your response. After looking at it some more, I was able to find a workable solution. As you stated above, the calculated columns were returning a 1 for what ever Status was in the Status column, for each Unique ID. But when the status changes, I needed to have the old status show a 0, with the new status showing 1.
The solution I found was to create a calculated column to show the most recent date for a status:
| Unique ID | Status | Date From | Previous Status | Previous Date | Research Count | Cultivation Count | Newest Status Date |
| 1 | Research | 3/28/2022 | 0 | 0 | 3/30/2022 | ||
| 1 | Cultivation | 3/30/2022 | Research | 3/28/2022 | 0 | 1 | 3/30/2022 |
Thanks again for your help.
-Dereck