Forum Discussion
DAX Cumulative Active Count with categories
Hi Forum,
Im stucking with the calculation of Cumulative Active Count of IT tickets (inquiries).
The raw data look like this:
| INQUIRY_ID | TEAM | MinActionDate | MaxActionDate | IA_ACTION |
| 555555 | Service | 01.04.2022 | 05.04.2022 | different Team assigned |
| 555555 | Support | 05.04.2022 | 09.04.2022 | different Team assigned |
| 555555 | Support | 09.04.2022 | 09.04.2022 | Ticket closed |
In this example, the Inquiry was active from 01.04.2022 - 09.04.2022.
If I filter for example Team Support, then it would be 05.04.2022 - 09.04.2022.
So the calculation should be dynamic.
It seems that below measure doesnt work here for the calculation:
VAR CurrentDate = MAX(Dim_Date[Datum])
RETURN
CALCULATE(
DISTINCTCOUNTROWS(Fact_Inquiries),
Fact_Inquiries[MinActionDate] <= CurrentDate, -- Inquiry started on or before CurrentDate
Fact_Inquiries[MaxActionDate] >= CurrentDate -- Inquiry ended on or after CurrentDate
)
Normally, I use this measure often but til now I only had use cases with 1 row per Id.
The result of this measure in the mentioned usecase is extremely high.
Does someone know, how to fix this?
Thanks for any help.
Kind regards,
DataHero
6 Replies
- vanessafvg
Community Champion
what is your expected result, please provide what you expect so that its clearly undertood. are you expecting the answer to be 2 when filter by support?
- DataHero
Helper I
Hi vanessafvg ,
result should be 1 because its the same inquiry_id: 555555- vanessafvg
Community Champion
ah ok, why not using distinctcount on the id instead?
VAR CurrentDate =
MAX ( Dim_Date[Datum] )
RETURN
CALCULATE (
DISTINCTCOUNT ( Fact_Inquiries[id] ),
Fact_Inquiries[MinActionDate] <= CurrentDate,
-- Inquiry started on or before CurrentDate
Fact_Inquiries[MaxActionDate] >= CurrentDate -- Inquiry ended on or after CurrentDate
)
- hnguy71
Super User
Hi DataHero
I don't believe your cummulative total is correct. You're current calculation is trying to return all records within a specific range but what you really want is the unique count of active tickets and doing a rolling sum.Try this instead:
Active_Tickets = // what is the current date in context? VAR _Date = MAX(Dim_Date[Datum]) RETURN /* Only interested in count of active tickets, therefore distinct count of inquiries. Remove filter on date table to get all results from all dates in context. Add filter for only active tickets for that day rolling total for all tickets */ CALCULATE( DISTINCTCOUNT(Fact_Inquiries[INQUIRY_ID]), ALL(Dim_Date), Fact_Inquiries[IA_ACTION] <> "TICKET CLOSED", Dim_Date[Datum] <= _Date )