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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
PowerbiLearnuk
New Member

Cumulative count with status

Hi, 

I am new here but I have been a user of the forums for long time. Hats off to all the lovely people out there who is helping others with the answers.

 

Here my question: I have requirement with cumulative count of approved connectors by different approval status and by quarter which should show only last 4 quarters inlcuding the present quarter if there is no data for any quarter it has to take value of previous quarter and present that. 

I have connectors table like below

connectoridcreateddateapprovaldateapprovalstatus
130/09/201620/06/2022niche
218/7/201710/07/2022standard
310/10/201610/07/2022standard
410/03/201828/08/2022standard
510/10/201630/10/2022standard
610/03/201801/02/2023niche
721/05/201910/03/2023standard

 

Expected result is 

QuarterStatusTotals for StatusCumulative for quarters
Q3-2022niche14

Q3-2022

standard34
Q4-2022niche15
Q4-2022standard45
Q1-2023niche27
Q1-2023standard57
Q2-2023nicheno data - copy from previous quarterno data - copy from previous quarter
Q2-2023standardno data - copy from previous quarterno data - copy from previous quarter

 

If i get the data like this above then my Line and stacked column chart will give 

Q3-2022 - column bar with 4 with a division of 1 and 3 niche and standard

Q4-2022 - column bar with 5 with a division of 1 and 4 niche and standard

 

I have done the measure for total status = COUNT(Connectors[Status])

Total Cumulative Connectors = CALCULATE(

                                                        Connectors[total status],

                                                        FILTER(

                                                               ALL(Connectors[approvaldate]),

                                                               Connectors[approvaldate]<= MAX(Connectors[approvaldate])
                                                         )
using the above 2 measures, its giving same for total status and Total Cumulative Connectors.
also it doesn't give me like the table which I am expecting above. it gives

Quarter    Status          Total status   Total Cumulative Connectors 

Q3-2022   niche           1                    1

Q3-2022   standard     3                     3

Q4-2022   standard     1                     1

Q1-2023   niche           1                     1

Q1-2023   standard      1                     1

Q2-2023     

 

Sorry about the long post, it will be great, if anyone can help me getting the desired result. These are all made up numbers, as I can't share the data because of confidentiality.  Thank you.

3 REPLIES 3
PowerbiLearnuk
New Member

Hello all, any help here is very much appreciated. Thank you very much. 

EricVieira
New Member

Hey buddy, I have a big question with a big answer. Jokes aside, here it is.😂

To create a DAX measure that calculates a cumulative count of approved connectors by different approval status and by quarter, and shows only the last 4 quarters, including the current quarter, while taking the value of the previous quarter if there is no data for any quarter, you can use the following DAX formula:

Approved Connectors Cumulative Count =
VAR QuarterEndDate =
IF(
NOT(ISFILTERED('DateTable'[Quarter])),
MAX('DateTable'[Date]),
MAX('DateTable'[QuarterEnd])
)
VAR QuartersToInclude = CALCULATETABLE(
VALUES('DateTable'[Quarter]),
'DateTable'[QuarterEnd] <= QuarterEndDate,
'DateTable'[QuarterEnd] >= QuarterEndDate - 364
)
VAR StatusValues = VALUES('ConnectorTable'[ApprovalStatus])
RETURN
SUMX(
QuartersToInclude,
VAR QuarterEndDate = 'DateTable'[QuarterEnd]
RETURN
IF(
ISBLANK(
CALCULATE(
DISTINCTCOUNT('ConnectorTable'[ConnectorID]),
FILTER(
'ConnectorTable',
'ConnectorTable'[ApprovalStatus] IN StatusValues
&& 'ConnectorTable'[ApprovalDate] <= QuarterEndDate
)
)
),
IF(
QuarterEndDate = MIN('DateTable'[QuarterEnd]),
0,
[Approved Connectors Cumulative Count]
),
CALCULATE(
DISTINCTCOUNT('ConnectorTable'[ConnectorID]),
FILTER(
'ConnectorTable',
'ConnectorTable'[ApprovalStatus] IN StatusValues
&& 'ConnectorTable'[ApprovalDate] <= QuarterEndDate
)
)
)
)

Hi Eric, 😂 thanks for the long answer. I have tried this, where the line is VAR QuarterEndDate = 'DateTable'[QuarterEnd] its showing the error and it says 'DateTable[QuarterEnd] does not exist, so, I have changed it to VAR QuarterEndDate = MAX( 'DateTable'[QuarterEnd]) and its stopped showing the error. The result is giving all the statuses for every quarter which is good. however the cumulative is not working its giving the values from that specific quarter only, its not adding the values from the previous quarter when the numbers are there and when numbers are not there as well. so, apart from cumulative other things are working. Thank you.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors