Forum Discussion
ajwhitty
Sep 16, 2023Copper Contributor
Finding unique values in a cumulative range
Hi, I've been grappling over finding a way how many open and closed instances (I'll call them packages) per month, but I need a cumulative value of unique customers.
So from the data table, I want the values to be:
Package Type A:
2 unique customers in April, 2 unique customers in May and then for months after, just 1 Unique customer for package type A
I've tried using the UNIQUE function, with VSTACK and whilst I can get unique values of the new packages in month and unique values of the closed packages in month, I can't seem to crack a balance per month.
I'm sure this really simple but I don't seem to have the imagination to make it work. Please help 🙂
Customer Number | Package | Start Date | End Date |
123456 | A | 15/04/2023 | 15/05/2023 |
123456 | A | 15/04/2023 | Open |
123456 | A | 01/06/2023 | 25/06/2023 |
456789 | B | 01/04/2023 | 31/08/2023 |
456789 | B | 01/07/2023 | Open |
456789 | B | 01/04/2023 | 25/06/2023 |
654321 | A | 01/04/2023 | 31/05/2023 |
654321 | A | 01/05/2023 | 31/05/2023 |
- Patrick2788Silver Contributor
- PeterBartholomew1Silver Contributor
- PeterBartholomew1Silver Contributor
= LET( distinctPairing, UNIQUE(Table1[[Customer Number]:[Package]]), customer, TAKE(distinctPairing,,1), package, TAKE(distinctPairing,,-1), monthStart, TRANSPOSE(UNIQUE(1 + EOMONTH(+Table1[Start Date], -1))), monthEnd, EOMONTH(monthStart, 0), counts, COUNTIFS( Table1[Customer Number], customer, Table1[Package], package, Table1[Start Date], ">="&monthStart, Table1[Start Date], "<="&monthEnd ), VSTACK( HSTACK({"Customer","Package"}, TEXT(monthStart, "mmm yy")), HSTACK(distinctPairing, counts) ) )