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
GRG2001
Frequent Visitor

Filter a measure weekly that contains a cumulative/running total sum of days

Hi!

 

I have a simple Measure that contains the running total of certain data that is counted by days. It was generated by using the following DAX code:

 

Medida = CALCULATE(
SUM('X'[Count]),
FILTER(ALL(X), 'X'[Data_mes] <= MAX('X'[Data_mes]))
)
 
However, I would like to have it filtered by weekly. So, for example: 01/11/2023 to 08/11/2023 the total is 200. Instead of having, inside the Measure, the dates from 01/11/2023 to 08/11/2023 and each cumulative value inside them, I would like to have only the last day (that representes a whole week) and the value.
 
What I have now/desire:
 
GRG2001_1-1698850122655.png

 

Thx in advance!

 

4 REPLIES 4
Anonymous
Not applicable

Hi  @GRG2001 ,

 

This code will perform a cumulative calculation for each weekend grouping, and this result applies to the sample data scenario I created. I'm not sure if there are other filters in your data or if the fields are not in the same table, so you can change my code to your own table name and field names.

If it doesn't meet your desired outcome, can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data. problem and help you.

 

Best Regards,

Liu Yang

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  @GRG2001 ,

 

Here are the steps you can follow:

1. Create measure.

Medida =
SUMX(
    FILTER(
        ALL('Table'),
        YEAR('Table'[Date_mes])=YEAR(MAX('Table'[Date_mes]))&&
        WEEKNUM('Table'[Date_mes],2)=WEEKNUM(MAX('Table'[Date_mes]),2)&&
        'Table'[Date_mes]<=MAX('Table'[Date_mes])),[Count])

2. Result:

 

vyangliumsft_0-1699233106078.png

 

Best Regards,

Liu Yang

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

Thank you for the answer.

 

The running total restarts every week. Is that a way that I can modify the code you posted to keep the running total continue throughout the weeks?

 

Thanks again.

lbendlin
Super User
Super User

Please provide sample data (with sensitive information removed) that covers your issue or question completely, in a usable format (not as a screenshot). Leave out anything not related to the issue.
If you are unsure how to do that please refer to 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.

If you want to get answers faster please refer to https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

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!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.