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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Elwira_A
Frequent Visitor

How to create cumulative weighted average for every month in DAX

Hi I have an issue,
I try to calculate cumulative weightet average for every month (days and Total already are measures)
I have data: 

Elwira_A_0-1658913730823.png

And I what to have for every month:
Jan = (total * days) / days
Feb = (Jan(total*days) + Feb(total*days)) / (Jan(days) + Feb(days))
March = (Jan(total*days) + Feb(total*days) + Mar(total*days)) / (Jan(days) + Feb(days)+Mar(days))
and so on...
how it is possible in Dax?

of course I have data not in one table, but Total and Days - are already measures.

Thanks for help!

1 ACCEPTED SOLUTION
v-chenwuz-msft
Community Support
Community Support

Hi @Elwira_A ,

 

Maybe you can try this code to do that:

Measure =
VAR _s =
    SUMMARIZE (
        FILTER ( ALLSELECTED ( 'date' ), [Date] <= MAX ( 'Table'[Date] ) ),
        [Date].[Month],
        "sum*days", SUM ( 'Table'[Values] ) * [Days],
        "days", [Days]
    )
RETURN
    DIVIDE ( SUMX ( _s, [sum*days] ), SUMX ( _s, [days] ) )

 

Result:

vchenwuzmsft_0-1659348746403.png

 

Pbix in the end you can refer.

Best Regards

Community Support Team _ chenwu zhu

 

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

 

 

View solution in original post

4 REPLIES 4
v-chenwuz-msft
Community Support
Community Support

Hi @Elwira_A ,

 

Maybe you can try this code to do that:

Measure =
VAR _s =
    SUMMARIZE (
        FILTER ( ALLSELECTED ( 'date' ), [Date] <= MAX ( 'Table'[Date] ) ),
        [Date].[Month],
        "sum*days", SUM ( 'Table'[Values] ) * [Days],
        "days", [Days]
    )
RETURN
    DIVIDE ( SUMX ( _s, [sum*days] ), SUMX ( _s, [days] ) )

 

Result:

vchenwuzmsft_0-1659348746403.png

 

Pbix in the end you can refer.

Best Regards

Community Support Team _ chenwu zhu

 

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

 

 

It is great! I was looking for it! Thank you!! 🙂

amitchandak
Super User
Super User

@Elwira_A , Try a measure like below. I am using date table

 

Cumm = CALCULATE(averageX(values('Date'[Date]),calculate(SUM(Sales[Sales Amount]))) ,filter(allselected('Date'),'Date'[date] <=max('Date'[date])))

 

 


To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

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

Hi,
I also use a date table.
But it isnt a solution, only for Total it is working, but when I multiply Total * Days = I have wrong data.
so the question is how to do it to get good results.

Thanks!

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.