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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
ineedham
Helper I
Helper I

How to create a measure calculating Cumulative Count by Year based on a specific value

I am trying to create a measure that returns the cumulative total of Pro licenses each year. The data looks like the table on the left, and I want it to return the values on the right:

 

pro license table.jpg

 

I’m able to create the following measure:

 

Cumulative Licenses =
CALCULATE (
    COUNTX ( 'Power BI Licenses', [License Status] = "Pro" ),
    FILTER (
        'Power BI Licenses',
        [Pro License Start Year]
            <= MAX ( [Pro License Start Year] )
    )
)

 

…but it won’t work in the line chart visual.  I get this error:

 

MdxScript(Model) (4, 86) Calculation error in measure Power BI Licenses'[Cumulative Licenses]: The function COUNTX cannot work with values of type Boolean.

 

I tried it with COUNTAX instead of COUNTX, and it works with the visual, but doesn’t return the running totals.

 

Also not having luck with 

 
COUNTROWS(
              FILTER(
                   SUMMARIZE (
1 ACCEPTED SOLUTION
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @ineedham ,

For your requirement, please try the measure below.

 

Measure = 
IF (
    MAX ( 'Table1'[License Status] ) = "",
    BLANK (),
    CALCULATE (
        COUNTROWS ( 'Table1' ),
        FILTER (
            ALL ( Table1 ),
            'Table1'[Pro License start year] <= MAX ( 'Table1'[Pro License start year] )
                && 'Table1'[License Status] <> ""
        )
    )
)

Here is the output.

 

Capture.PNG

You also could have a reference of my attachment.

If you still need help, please share a dummy pbix file which can reproduce the scenario, so that we can help further investigate on it? You can upload it to OneDrive and post the link here. Do mask sensitive data before uploading.

Best  Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @ineedham ,

For your requirement, please try the measure below.

 

Measure = 
IF (
    MAX ( 'Table1'[License Status] ) = "",
    BLANK (),
    CALCULATE (
        COUNTROWS ( 'Table1' ),
        FILTER (
            ALL ( Table1 ),
            'Table1'[Pro License start year] <= MAX ( 'Table1'[Pro License start year] )
                && 'Table1'[License Status] <> ""
        )
    )
)

Here is the output.

 

Capture.PNG

You also could have a reference of my attachment.

If you still need help, please share a dummy pbix file which can reproduce the scenario, so that we can help further investigate on it? You can upload it to OneDrive and post the link here. Do mask sensitive data before uploading.

Best  Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

That worked.  Thank you!

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors