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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
bignadad
Helper I
Helper I

Monthly Average of Running Total

I have a running total of assets by month and this is working fine.

 

bignadad_0-1708365314270.png

Here is my formula for the running total

RT Total = 
    VAR __Date = MAX(MasterDate[Dates])
    VAR __Table = FILTER(ALLSELECTED(MasterDate),MasterDate[Dates] <= __Date)
RETURN
    SUMX(__Table,[Total])

Total measure is

Total = CALCULATE(SUM(glentry[amount]))

The average should be 

22,393,778.19

 

Everything I have tried will not work.

What DAX formula will give me this result?

 

4 REPLIES 4
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how the semantic model looks like, but please try something like below whether it suits your requirement.

 

Running average =
VAR __Date =
    MAX ( MasterDate[Dates] )
VAR __Table =
    SUMMARIZE (
        FILTER ( ALLSELECTED ( MasterDate ), MasterDate[Dates] <= __Date ),
        MasterDate[YearMonth Sort Column]
    )
RETURN
    AVERAGEX ( __Table, [Total] )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

I tried what you suggested

Average Invnetory = 
VAR __Date =
    MAX ( MasterDate[Dates] )
VAR __Table =
    SUMMARIZE (
        FILTER ( ALLSELECTED ( MasterDate ), MasterDate[Dates] <= __Date ),
        MasterDate[YearMonth]
    )
RETURN
    AVERAGEX ( __Table, [Total] )

 

But it returns 2.49 million

bignadad_0-1708366674358.png

Here is my master date table

bignadad_1-1708366708198.png

 

Could it be because of this blank year month value? 

bignadad_2-1708366989490.png

 

I found the issue with the blank value and removed it. this is what I have when I look at YearMonth with my CurrentInventory Total and CurrentInventory Running total

bignadad_3-1708367476338.png

This is my Dax based on your suggestion for running total

 

Average Invnetory = 
VAR __Date =
    MAX ( MasterDate[Dates] )
VAR __Table =
    SUMMARIZE (
        FILTER ( ALLSELECTED ( MasterDate ), MasterDate[Dates] <= __Date ),
        MasterDate[YearMonth]
    )
RETURN
    AVERAGEX ( __Table, [RT Current Inventory])

 

RT Current Inventory is

 

RT Current Inventory = 
    VAR __Date = MAX(MasterDate[Dates])
    VAR __Table = FILTER(ALLSELECTED(MasterDate),MasterDate[Dates] <= __Date)
RETURN
    SUMX(__Table,[Current Inventory])

 

This gives me 19326079.35 which is the average of all years.

So its the correct amount for all years but when I filter to 2023 i get this value

bignadad_4-1708367666683.png

What I would like it the average for the currently selected year. which should be 22,393,778.19 in 2023.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors