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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
bkoeppler
Regular Visitor

Limits on Cumulative Count Measure

Hello, 

 

I've written a cumulative count measure that counts the rows up based off a column that is either blank if the task has not been closed or has a closing date in it if it has been closed. I cannot find a way to only take the cumulative count of rows where there is a date in the column and not add the row if it is blank. Additional to this, I only want the graph to start from when the first closing date is entered and stop on the graph at today's date. Currently it shows data for every date that I have in my Date Dimension table, which is flat lining the line graph out way too far.

 

CumulativePunchlistClosed =
VAR CurrentDate = MAX('DimDate (REF)'[DimDate])
RETURN
    CALCULATE(
        COUNTROWS('Closed Punch Query'),
        FILTER(
            ALLSELECTED('Closed Punch Query'),
            'Closed Punch Query'[Workflow - Closing Date] <= CurrentDate
        )
    )
 
Punchlist DAX Question.png
 
Chat GPT also gave the below but it is even worse than the above. 
 
CumClose2 =
VAR MinClosingDate = CALCULATE(MIN('Closed Punch Query'[Workflow - Closing Date]), 'Closed Punch Query'[Workflow - Closing Date] <> BLANK())
VAR MaxClosingDate = MAX('Reporting Date to Load'[Reporting Date])
VAR SelectedDates =
    FILTER(
        ALL('DimDate (REF)'),
        'DimDate (REF)'[DimDate] >= MinClosingDate && 'DimDate (REF)'[DimDate] <= MaxClosingDate
    )
RETURN
    CALCULATE(
        COUNTROWS('Closed Punch Query'),
        'Closed Punch Query'[Workflow - Closing Date] <> BLANK(),
        'DimDate (REF)'[DimDate] IN SelectedDates
    )
1 ACCEPTED SOLUTION
v-cgao-msft
Community Support
Community Support

Hi @bkoeppler ,

 

Please try:

CumulativePunchlistClosed = 
VAR _min_date =
    MIN ( 'Closed Punch Query'[Workflow - Closing Date] )
VAR _max_date =
    TODAY ()
VAR CurrentDate =
    MAX ( 'DimDate (REF)'[DimDate] )
RETURN
    IF (
        CurrentDate >= _min_date
            && CurrentDate <= _max_date,
        CALCULATE (
            COUNTROWS ( 'Closed Punch Query' ),
            FILTER (
                ALLSELECTED ( 'Closed Punch Query' ),
                'Closed Punch Query'[Workflow - Closing Date] <= CurrentDate
                    && NOT ISBLANK('Closed Punch Query'[Workflow - Closing Date])
            )
        )
    )

vcgaomsft_1-1692067827609.png

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

View solution in original post

2 REPLIES 2
v-cgao-msft
Community Support
Community Support

Hi @bkoeppler ,

 

Please try:

CumulativePunchlistClosed = 
VAR _min_date =
    MIN ( 'Closed Punch Query'[Workflow - Closing Date] )
VAR _max_date =
    TODAY ()
VAR CurrentDate =
    MAX ( 'DimDate (REF)'[DimDate] )
RETURN
    IF (
        CurrentDate >= _min_date
            && CurrentDate <= _max_date,
        CALCULATE (
            COUNTROWS ( 'Closed Punch Query' ),
            FILTER (
                ALLSELECTED ( 'Closed Punch Query' ),
                'Closed Punch Query'[Workflow - Closing Date] <= CurrentDate
                    && NOT ISBLANK('Closed Punch Query'[Workflow - Closing Date])
            )
        )
    )

vcgaomsft_1-1692067827609.png

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

That's Great! Thanks for your help Gao - worked perfectly.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.