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
Kraftfood
Helper I
Helper I

Running total of a percentage measure DAX

Hello, I'm not sure if this situation has been answered before, I tried a few solutions from other posts but none worked.

I have a series of sales, dated, and an objective sales for 2022.

I created a measure that calculates the % of completion simply by dividing sales by objectives.

Now I would like the running total % of this completion. I tried to use this DAX formula but no success:

Running total = SUMX(FILTER(ALLSELECTED('TABLE'[DATE]),'TABLE'[DATE]<=MAX('TABLE'[DATE])),[Completion %])

Does anyone encountered the same issue?

Screenshot of the table in Excel, I want the same in BI but cannot get the last column.

Kraftfood_0-1662558397572.png

 

 

1 ACCEPTED SOLUTION

@Kraftfood 

Thanks for the file!

Here goes...

Create a Calendar table using:

Calendar Table =
ADDCOLUMNS (
    CALENDAR ( MIN ( Sales[Operation date] ), MAX ( Sales[Operation date] ) ),
    "MonthNum", MONTH ( [Date] ),
    "Month", FORMAT ( [Date], "MMM" ),
    "Year", YEAR ( [Date] )
)

Make sure the date fields are formatted as type Date

Create a relationship between the Calendar Table and Sales via the corresponding Date fields. The model looks like this:

model.png

Next create the following measures:

 

Sum Sales K = 
SUM(Sales[Revenue K])
Sum Budget = 
SUM(Budget[Objective])
% Completion Sales k =
VAR _Running =
    CALCULATE (
        [Sum Sales K],
        FILTER (
            ALLSELECTED ( 'Calendar Table'[Date] ),
            'Calendar Table'[Date] <= MAX ( 'Calendar Table'[Date] )
        )
    )
RETURN
    DIVIDE ( _Running, [Sum Budget] )

or if you prefer using SUMX

SUMX completion % =
SUMX (
    FILTER (
        ALLSELECTED ( 'Calendar Table'[Date] ),
        'Calendar Table'[Date] <= MAX ( 'Calendar Table'[Date] )
    ),
    [Completion %]
)

Use the date field from the Calendar Table in the visual to get:

new.png

I've attached the sample PBIX file





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

13 REPLIES 13
PaulDBrown
Community Champion
Community Champion

Try:

Running Total % =
VAR _Sales = CALCULATE([Sum Sales], FILTER (ALLSELECTED (Table[Date]), Table[Date]<= MAX(Table[Date]))

VAR _Budget = AVERAGEX(VALUES(Table[Date]), [Sum Budget)

RETURN

DIVIDE(_Sales, _Budget)

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Hi thanks for the help. I changed the formula for the Sum Sales and Sum Budget + added a ")" at the end of both VAR, see below:

VAR _Sales = CALCULATE(Sum(Table[Sales]), FILTER (ALLSELECTED (Table[Date]), Table[Date]<= MAX(Table[Date])))

VAR _Budget = AVERAGEX(VALUES(Table[Date]), Sum(Table[Budget]))

RETURN

DIVIDE(_Sales, _Budget)

 

But I still have the same values as the column completion

How is your data structured? Do you have a date table? Are sales and budget from different tables?

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






I have a star schema. I don't have a data table, the date column is from the main table, one line per transactions. Sales is included in the main table, however the budget is from another table.

Let me fix my previous answer:

 

VAR _Sales = CALCULATE(Sum(Sales[Sales]), FILTER (ALLSELECTED (Sales[Date]), Sales[Date]<= MAX(Sales[Date])))

VAR _Budget = AVERAGEX(VALUES(Table[Date]), Sum(Budget[Budget]))

RETURN

DIVIDE(_Sales, _Budget)

Let's see if this works (slight variation), though you should ideally be working with a Date Table

 

% Running Total =
VAR _Sales =
    CALCULATE (
        [Sum Sales],
        FILTER ( ALLSELECTED ( Table ), Table[date] <= MAX ( Table[date] ) )
    )
VAR _Budget =
    AVERAGEX ( VALUES ( Table[date] ), [Budget] )
RETURN
    DIVIDE ( _Sales, _Budget )

 

Or

 

Running Total % =
SUMX (
    FILTER ( ALLSELECTED ( Table ), Table[date] <= MAX ( Table[date] ) ),
    CALCULATE ( [Completion] )
)

 

result.png

 

 

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Tried the first one but, the [Budget] in AVERAGEX has to be a measure.

For the second one I have weird figures...: 

Kraftfood_0-1662565168012.png

 

It would be easier if you provided sample non-confidential data of the tables involved. Otherwise it's guess work





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Hi Paul sorry I have been busy.

Here is the link to a situtation similar to mine. 

 

https://drive.google.com/file/d/1R2db5dbrFQVlPSBjTsARYX9focl7Jxjf/view?usp=sharing

 

https://1drv.ms/u/s!AkGwzt_UiPRCg21RqEzdVMiJ01hY?e=zaaK15

 

Let me know if one of the links work, I have issues sharing power bi documents via google drive and 1 drive.

@Kraftfood 

Thanks for the file!

Here goes...

Create a Calendar table using:

Calendar Table =
ADDCOLUMNS (
    CALENDAR ( MIN ( Sales[Operation date] ), MAX ( Sales[Operation date] ) ),
    "MonthNum", MONTH ( [Date] ),
    "Month", FORMAT ( [Date], "MMM" ),
    "Year", YEAR ( [Date] )
)

Make sure the date fields are formatted as type Date

Create a relationship between the Calendar Table and Sales via the corresponding Date fields. The model looks like this:

model.png

Next create the following measures:

 

Sum Sales K = 
SUM(Sales[Revenue K])
Sum Budget = 
SUM(Budget[Objective])
% Completion Sales k =
VAR _Running =
    CALCULATE (
        [Sum Sales K],
        FILTER (
            ALLSELECTED ( 'Calendar Table'[Date] ),
            'Calendar Table'[Date] <= MAX ( 'Calendar Table'[Date] )
        )
    )
RETURN
    DIVIDE ( _Running, [Sum Budget] )

or if you prefer using SUMX

SUMX completion % =
SUMX (
    FILTER (
        ALLSELECTED ( 'Calendar Table'[Date] ),
        'Calendar Table'[Date] <= MAX ( 'Calendar Table'[Date] )
    ),
    [Completion %]
)

Use the date field from the Calendar Table in the visual to get:

new.png

I've attached the sample PBIX file





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Do you know why when looking at the figures through a table like that we don't get the right % please?

 

Kraftfood_0-1662972749411.png

 

 

Kraftfood_1-1662972766175.png

 

You need to use the Category field from the Budget Table:

matrix.png

 

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Thank you!

Thank you very much! Was it just a date issue?

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.