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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Cooler
Frequent Visitor

Running total, self filtering by index column

Hello everyone.
I have a sales table and i drop  few columns from it into table visual,

product_group_id - product group
index - unique number of sale

the main column is a index - from 0, all the values of index are unique. In sales table i have around 300K rows.

Cooler_0-1729618819606.png

 


And i need to calculate in measure running total not a general but within the group, so i need for every sale in sales table calculate running total within product group, based on index, e.g. all sales of the same group before and including current sale by index.
here is my code

sales_runn_total8 =
            VAR cur_index = SELECTEDVALUE ( sales[Index] )
            VAR gr_id = MAX ( products[IDProductGroup] )
            VAR sale_table =
                CALCULATETABLE(
                    sales,
                        REMOVEFILTERS ( sales ),
                            products[IDProductGroup] = gr_id
                            )
        VAR run_total =
            SUMX(FILTER(sale_table, [Index] <= cur_index), [ammount])  
                       
        RETURN
 run_total
 
basically it works, but the measure is slow , it takes about 30-40 sec , and the reason of it is filtering nested sales table with current index in visual. So it works very fast if i calculate all sales of the current group, but the moment i am trying using any variable from base table, sales table, like index or any other, it became 10 times slower than before ((
please any ideas of workaround welcome!))
p.s. calculated column and PQ are not considering ))
2 REPLIES 2
lbendlin
Super User
Super User

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).

Do not include sensitive information. Do not include anything that is unrelated to the issue or question.

Need help uploading data? https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

Please show the expected outcome based on the sample data you provided.

Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Hello. i made a correction to my initial post and here is my PBIX file .
Example.pbix

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.