Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
I'm trying to get a running count of active projects in each month. I've managed to do two measures that calculate the cumulative number of projects created, the same for projects closed, and then take one from the other.
Data is set out like:
MainCode | Type | CreatedDate | DoneDate |
1 | 1 | 01/01/2018 | 25/01/2018 |
2 | 1 | 05/01/2018 | |
3 | 1 | 03/02/2018 | 05/02/2018 |
4 | 1 | 04/02/2018 | |
5 | 1 | 20/02/2018 | 10/06/2018 |
6 | 1 | 03/03/2018 |
So the running active count would be:
Jan: 1
Feb: 3 (as the 20/02 project didn't close until June)
Mar: 4
(NB: Active relationship between [CreatedDate] and [Calendar Date] from my Date Table, inactive join between [DoneDate] and [Calendar Date]. Some [Types] are also "2" or "3" which I don't want to count)
_ActiveCasesInMonth =
VAR AllProjs = CALCULATE(DISTINCTCOUNT(MainData[MainCode]),MainData[Type]="1",FILTER ( ALL( DateTable ), DateTable[Calendar Date] <= MAX ( DateTable[Calendar Date] ) ))
VAR ClosedProjs = CALCULATE(DISTINCTCOUNT(MainData[MainCode]),MainData[Type]="1",USERELATIONSHIP(DateTable[Calendar Date],MainData[DoneDate]),FILTER ( ALLSELECTED( DateTable ), DateTable[Calendar Date] <= MAX ( DateTable[Calendar Date] ) ))
Return
AllProjs-ClosedProjs
Problem is, I'm doing a running count from 01/01/2018 (as some projects from then are still not closed), but I currently only want to display the current financial year (01/04/2019 to 31/03/2020) in a visual - when I filter the bar chart to this FY (using a MonthYear column from the Date Table) the running total of 'ClosedProjs' is changing along with it.
I'm guessing it's my use of ALLSELECTED in that's allowing the filters to have an effect, but using ALL gives me a wrong total to begin with.
If someone can point me in the right direction that would be great.
Thank you
Solved! Go to Solution.
Right, I went away and had a cup of tea and, of course, that's all I needed to see the solution:
VAR ClosedProjs = CALCULATE(DISTINCTCOUNT(MainData[MainCode]),MainData[Type]="1",USERELATIONSHIP(DateTable[Calendar Date],MainData[DoneDate]),Filter(All(DateTable),DateTable[Calendar Date] <=Max(DateTable[Calendar Date])),MainData[DoneDate])
Went with the ALL function, but remembed to use [DoneDate] as a filter in CALCULATE.
Right, I went away and had a cup of tea and, of course, that's all I needed to see the solution:
VAR ClosedProjs = CALCULATE(DISTINCTCOUNT(MainData[MainCode]),MainData[Type]="1",USERELATIONSHIP(DateTable[Calendar Date],MainData[DoneDate]),Filter(All(DateTable),DateTable[Calendar Date] <=Max(DateTable[Calendar Date])),MainData[DoneDate])
Went with the ALL function, but remembed to use [DoneDate] as a filter in CALCULATE.
Been trying to fix this all day, and this was the answer - thank you so much!
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
15 | |
11 | |
8 | |
8 | |
8 |
User | Count |
---|---|
22 | |
13 | |
11 | |
10 | |
10 |