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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

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.

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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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