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

Don'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.

Reply
ExcelMonke
Super User
Super User

Cumulative count for missing data

Hello, 
I am trying to figure out how to calculate a cumulative count where, if a category returns 0, it will take the "previous" value. I have tried a couple methods but it doesn't seem to work. This must be a measure due to the size of the data set. 

This is my current DAX:

 

Cumulative Tester =
VAR _Count =
    CALCULATE (
        DISTINCTCOUNT ( Data[OrderId] ),
        FILTER (
            ALLSELECTED ( Data ),
            Data[DaystoRespond] <= MAX ( Data[DaystoRespond] )
        )
    ) + 0
VAR _Total =
    CALCULATE ( DISTINCTCOUNT (  Data[OrderId] ), ALLSELECTED ( Data) )
VAR _AccountForZero =
    CALCULATE (
        DISTINCTCOUNT (  Data[OrderId] ),
        FILTER (
            ALLSELECTED ( Data ),
            ( Data[DaystoRespond] - 1 )
                <= MAX ( Data[DaystoRespond] ) - 1
        )
    ) + 0
VAR _NoBlankCount =
    IF ( _Count = 0, _AccountForZero, _Count )
RETURN
    // DIVIDE(_NoBlankCount,_Total)
    _AccountForZero

 


This gives me the following result:

ExcelMonke_0-1722982787959.png

 

The intended result should be that, on row 26, the result should be 12948, instead of 0. 

Would anyone be able to help?

Thanks! 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





2 REPLIES 2
amitchandak
Super User
Super User

@ExcelMonke , Days to respond or bucket should come from seperate table. that will offer better result. Measn has a dimension


CALCULATE (
DISTINCTCOUNT ( Data[OrderId] ),
FILTER (
ALLSELECTED ( DaystoRespond),
DaystoRespond[DaystoRespond] <= DaystoRespond( Data[DaystoRespond] )
)
)

 

Or use window function, make sure all groupby of visual are using in window's relation

 

You can alos use new visual calculation runningsum

Continue to explore Power BI Window function Rolling, Cumulative/Running Total, WTD, MTD, QTD, YTD, FYTD: https://youtu.be/nxc_IWl-tTc
https://medium.com/@amitchandak/power-bi-window-function-3d98a5b0e07f

 

Visual Calculations in Power BI- February 2024 Update RUNNINGSUM, RANGE, MOVINGAVERAGE, COLLAPSE, COLLAPSEALL, EXPAND, EXPANDALL, FIRST, LAST, PREVIOUS, and NEXT
https://www.youtube.com/watch?v=bKD9T0EWgQo&list=PLPaNVDMhUXGYo50Ajmr4SgSV9HIQLxc8L

 

 

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Hello,
Thanks for the suggestion. For some context: I do have an additional table that is for Day bucket. This links to my data table which has an additional column which rounds the 'Data'[DaystoRespond] column. 

So - this connection is a One:Many from DayBucket[Bucket] to Data[DaystoRespond_Bucket]. 

Unfortunatey, the above recommended DAX did not work. 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.