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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Sum of a running total by Category

Hi,
I have report wheer the user chooses a year and Month (Example March, 2024) via a filter.  It displays Product and Sales for that Month.  It also has a running total for the Sales from the start of time.  All of this works.

ProductSalesTotal Sales
Radio1002,500
TV4,2009,300
Toaster50500

I have a card that shows the complete totals.  It shows:

Sales: 4,350Total Sales: 9,300


Total Sales should show: 12,300.

The

 

 

 

Total Sales = 

VAR SDt = SELECTEDVALUE ('DateTble'[Dt])

// Create a Running total of Sales by Product
VAR Result =
    CALCULATE (    
        SUM ('SalesTable'[Loss Incurred]),
        FILTER (ALL('SalesTable'), 'SalesTable'[AcctDt] <= SDt && 'SalesTable'[ProductID] = MAX ('SalesTable'[ProductID]))
    )

RETURN Result

 

 

 

How do I get the correct overall total?

5 REPLIES 5
Anonymous
Not applicable

Hi @Anonymous ,

 

What does your data model look like, please describe it with relevant screenshot information.

 

Best Regards,
Adamk Kong

Anonymous
Not applicable

Thanks for the reply from @amitchandak , please allow me to provide another insight:

 

Hi @Anonymous ,

 

You can achieve a similar effect with the help of hasonevalue function. Refer to below formula:

TotalSales =
VAR SDt =
    SELECTEDVALUE ( DateTable[Dt] )
VAR Result =
    CALCULATE (
        SUM ( 'Table'[Sales] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Date] <= SDt
                && 'Table'[Product] = MAX ( 'Table'[Product] )
        )
    )
RETURN
    IF (
        HASONEVALUE ( 'Table'[Product] ),
        Result,
        SUMX ( FILTER ( ALL ( 'Table' ), 'Table'[Date] <= SDt ), [Sales] )
    )

 

vkongfanfmsft_0-1715320363916.png

Best Regards,
Adamk Kong

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Hi, I do not know why but now my data is duplicating inside a different table visual.
This table has:

ProductDtSalesTotal Sales
TVMarch, 20244,2009,300
TVApril, 2024 9,300
etc.   



amitchandak
Super User
Super User

@Anonymous , Try like, measure should use date table in filter

 

Total Sales =

VAR SDt = SELECTEDVALUE ('DateTble'[Dt])

// Create a Running total of Sales by Product
VAR Result =
CALCULATE (
SUM ('SalesTable'[Loss Incurred]),
FILTER (ALL('DateTble'), 'DateTble'[Dt]] <= SDt )
)

 

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hi, This solution also duplicates my data inside a different table visual.
This table has:

ProductDtSalesTotal Sales
TVMarch, 20244,2009,300
TVApril, 2024 9,300
etc.   

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 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.