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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
yanisyes
Frequent Visitor

Cumulative total for a count function doesn't work when I filter with containsstring

Hello,
I have the data below 

yanisyes_1-1713869716431.png

 

 

I want to have the cumulative data only for the item that contain cat1.
I've used the formula below using containstring 

cat_1_only_cumulative=CALCULATE(
                COUNT(Table1[Row Label]),
                FILTER(ALLSELECTED(Table1[Attribute]),
                        Table1[Attribute]<=MAX(Table1[Attribute]) ),
                         FILTER(Table1,CONTAINSSTRING(Table1[Row Label],"cat1")
                        ))
It filters the row correctly but then the cumulative total are wrong I have this
yanisyes_3-1713869918444.png

 

and I was expecting this 
yanisyes_2-1713869852594.png

 

Could you please help me to solve this problem to get the good cumulative amounts after filtering by items only containing cat1.

 

Also is it possible to put the Measure cat_1_only_cumulative and then  Measure cat_2_cumulative in a table as row with the dates like the example below 

Row Label01/01/202502/01/202503/01/202504/01/202505/01/202506/01/2025TOTAL
cat_1_only_cumulative1234566
cat_2_cumulative     11
 
 
Thanks for your help.
 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @yanisyes ,

Please create measures like:

cat_1_only_cumulative = 
CALCULATE (
    COUNT ( Table1[Row Label] ),
    Table1[Attribute] <= MAX ( Table1[Attribute] ),
    CONTAINSSTRING(Table1[Row Label],"cat1") 
)
cat_2_only_cumulative = 
CALCULATE (
    COUNT ( Table1[Row Label] ),
    Table1[Attribute] <= MAX ( Table1[Attribute] ),
    CONTAINSSTRING(Table1[Row Label],"cat2") 
)

vcgaomsft_0-1713925168388.png

vcgaomsft_1-1713925195768.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 -- China Power BI User Group

View solution in original post

2 REPLIES 2
Ashish_Mathur
Super User
Super User

Hi,

Why are you trying to pass the Cat1 condition in the CALCULATE() function?  Why not give that condition in the FILTER() pane?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Hi @yanisyes ,

Please create measures like:

cat_1_only_cumulative = 
CALCULATE (
    COUNT ( Table1[Row Label] ),
    Table1[Attribute] <= MAX ( Table1[Attribute] ),
    CONTAINSSTRING(Table1[Row Label],"cat1") 
)
cat_2_only_cumulative = 
CALCULATE (
    COUNT ( Table1[Row Label] ),
    Table1[Attribute] <= MAX ( Table1[Attribute] ),
    CONTAINSSTRING(Table1[Row Label],"cat2") 
)

vcgaomsft_0-1713925168388.png

vcgaomsft_1-1713925195768.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 -- China Power BI User Group

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.