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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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.

4 REPLIES 4
EricVieira
Regular Visitor

Approved Connectors Cumulative Count :=
VAR CurrentQuarterEnd =
MAX('DateTable'[QuarterEnd])

VAR QuartersToInclude =
CALCULATETABLE(
VALUES('DateTable'[QuarterEnd]),
'DateTable'[QuarterEnd] <= CurrentQuarterEnd &&
'DateTable'[QuarterEnd] >= EDATE(CurrentQuarterEnd, -12)
)

VAR StatusValues =
VALUES('ConnectorTable'[ApprovalStatus])

RETURN
SUMX(
QuartersToInclude,
VAR ThisQuarterEnd = [QuarterEnd]
VAR Cumulative =
CALCULATE(
DISTINCTCOUNT('ConnectorTable'[ConnectorID]),
FILTER(
ALL('DateTable'),
'DateTable'[QuarterEnd] <= ThisQuarterEnd &&
'DateTable'[QuarterEnd] IN QuartersToInclude
),
FILTER(
'ConnectorTable',
'ConnectorTable'[ApprovalStatus] IN StatusValues &&
NOT(ISBLANK('ConnectorTable'[ApprovalDate]))

)
)
RETURN Cumulative
)

 

mudei!!

PowerbiLearnuk
New Member

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

EricVieira
Regular Visitor

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
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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