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
Robert1981
Helper II
Helper II

Calculate average over monthly sums

Hi,
I am trying to calculate the Inventory Turnover for one of our businesses. I am not sure how to build the dax in this case. In my data I have several levels of business/product information and I have different periods. The goal is to calculate the inventory total month average, for any level I put in my report.

 

Below is a sample of the data.

The goal is to calculate set up a formula that calculates the average interest in my matrix, taking into account the level I bring into the report and the date references (month, quarter, year) that I select.

 

Right now my formula keeps doing the average of all the individual values and not of the sum of the values for the specific month.

total CorpBusiness groupProduct FamilyProductDateValue
CorpBusiness1Family1Prod11/31/2023100
CorpBusiness1Family1Prod21/31/202315
CorpBusiness1Family2ProdA1/31/202345
CorpBusiness1Family2ProdB1/31/202355
CorpBusiness2Family3Prod11/31/2023250
CorpBusiness2Family3Prod21/31/2023300
CorpBusiness2Family4ProdA1/31/2023375
CorpBusiness2Family4ProdB1/31/2023400
CorpBusiness1Family1Prod12/28/2023105
CorpBusiness1Family1Prod22/28/202325
CorpBusiness1Family2ProdA2/28/202340
CorpBusiness1Family2ProdB2/28/202365
CorpBusiness2Family3Prod12/28/2023260
CorpBusiness2Family3Prod22/28/2023315
CorpBusiness2Family4ProdA2/28/2023375
CorpBusiness2Family4ProdB2/28/2023400
1 ACCEPTED SOLUTION

Problem solved by standarzing the KPI. Every month's KPI is calculated using the 3-month moving average. Now it doesn't matter anymore if I looking at a quarter or single month. The calculation is always the same

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi @Robert1981 

 

You can try the following steps.

 

1. Create a calculated table as follows and create a slicer based on this table

Date = VALUES('Table'[Date])

vxuxinyimsft_0-1705556053682.png

 

vxuxinyimsft_3-1705557844569.png

 

2. Create a measure as follows

valueaverage = 
CALCULATE (
    AVERAGE ( 'Table'[Value] ),
    FILTER (
        ALLEXCEPT ( 'Table', 'Table'[Business group] ),
        YEAR ( 'Table'[Date] ) = YEAR ( SELECTEDVALUE ( 'Date'[Date] ) )
            && MONTH ( 'Table'[Date] ) = MONTH ( SELECTEDVALUE ( 'Date'[Date] ) )
    )
)

 

vxuxinyimsft_1-1705556602704.png

 

vxuxinyimsft_2-1705556659253.png

Is this the result you expect?

 

If I've misunderstood you, please provide detailed sample data and the results you are hoping for: How to provide sample data in the Power BI Forum - Microsoft Fabric Community

 

Best Regards,
Community Support Team _Yuliax

 

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

Not exactly:
What I am trying to accomplish is that:
When I display months - the formula will do (sum of inventory specific month + sum of inventory previous month) / 2
When I display quarters - the formula will do (sum of inventory last month of quarter + sum of inventory last month of previous quarter) / 2  
Or it can take the average of all the sums per month within each quarter

I tried to extend the dataset a bit to show what I mean:

  1/31/20232/28/20233/31/20234/30/20235/31/20236/30/2023
SumFamily1115130115126.5143126.5
 Family2100105105110115.5115.5
        
AveFamily1 122.5122.5120.75134.75134.75
 Family2 102.5105107.5112.75115.5

 

  Q1Q2
SumFamily1115126.5
 Family2105115.5
    
AveFamily1 120.75
 Family2 110.25

 

otal CorpBusiness groupProduct FamilyProductDateQuarter Value 
CorpBusiness1Family1Prod11/31/2023Q1 100.00
CorpBusiness1Family1Prod21/31/2023Q1   15.00
CorpBusiness1Family2ProdA1/31/2023Q1   45.00
CorpBusiness1Family2ProdB1/31/2023Q1   55.00
CorpBusiness2Family3Prod11/31/2023Q1 250.00
CorpBusiness2Family3Prod21/31/2023Q1 300.00
CorpBusiness2Family4ProdA1/31/2023Q1 375.00
CorpBusiness2Family4ProdB1/31/2023Q1 400.00
CorpBusiness1Family1Prod12/28/2023Q1 105.00
CorpBusiness1Family1Prod22/28/2023Q1   25.00
CorpBusiness1Family2ProdA2/28/2023Q1   40.00
CorpBusiness1Family2ProdB2/28/2023Q1   65.00
CorpBusiness2Family3Prod12/28/2023Q1 260.00
CorpBusiness2Family3Prod22/28/2023Q1 315.00
CorpBusiness2Family4ProdA2/28/2023Q1 375.00
CorpBusiness2Family4ProdB2/28/2023Q1 400.00
CorpBusiness1Family1Prod13/31/2023Q1   95.00
CorpBusiness1Family1Prod23/31/2023Q1   20.00
CorpBusiness1Family2ProdA3/31/2023Q1   25.00
CorpBusiness1Family2ProdB3/31/2023Q1   80.00
CorpBusiness2Family3Prod13/31/2023Q1 270.00
CorpBusiness2Family3Prod23/31/2023Q1 330.00
CorpBusiness2Family4ProdA3/31/2023Q1 340.00
CorpBusiness2Family4ProdB3/31/2023Q1 380.00
CorpBusiness1Family1Prod14/30/2023Q2 110.00
CorpBusiness1Family1Prod24/30/2023Q2   16.50
CorpBusiness1Family2ProdA4/30/2023Q2   49.50
CorpBusiness1Family2ProdB4/30/2023Q2   60.50
CorpBusiness2Family3Prod14/30/2023Q2 275.00
CorpBusiness2Family3Prod24/30/2023Q2 330.00
CorpBusiness2Family4ProdA4/30/2023Q2 412.50
CorpBusiness2Family4ProdB4/30/2023Q2 440.00
CorpBusiness1Family1Prod15/31/2023Q2 115.50
CorpBusiness1Family1Prod25/31/2023Q2   27.50
CorpBusiness1Family2ProdA5/31/2023Q2   44.00
CorpBusiness1Family2ProdB5/31/2023Q2   71.50
CorpBusiness2Family3Prod15/31/2023Q2 286.00
CorpBusiness2Family3Prod25/31/2023Q2 346.50
CorpBusiness2Family4ProdA5/31/2023Q2 412.50
CorpBusiness2Family4ProdB5/31/2023Q2 440.00
CorpBusiness1Family1Prod16/30/2023Q2 104.50
CorpBusiness1Family1Prod26/30/2023Q2   22.00
CorpBusiness1Family2ProdA6/30/2023Q2   27.50
CorpBusiness1Family2ProdB6/30/2023Q2   88.00
CorpBusiness2Family3Prod16/30/2023Q2 297.00
CorpBusiness2Family3Prod26/30/2023Q2 363.00
CorpBusiness2Family4ProdA6/30/2023Q2 374.00
CorpBusiness2Family4ProdB6/30/2023Q2 418.00

Problem solved by standarzing the KPI. Every month's KPI is calculated using the 3-month moving average. Now it doesn't matter anymore if I looking at a quarter or single month. The calculation is always the same

amitchandak
Super User
Super User

@Robert1981 , Suppose you want to add till day and then Avg , prefer to use date table joined iwth date and use date , month year from date table

 

Averagex(Summarize(Table, Date[Date], "_1", Sum(Table[Qty]) ), [_1])

 

Avg over Product Date

 

 

Averagex(Summarize(Table, Table[Product], Date[Date], "_1", Sum(Table[Qty]) ), [_1])

 

 

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
Daniel29195
Super User
Super User

can you please share the visual and the formula you are using  ? 

 

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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