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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Chava1881
Helper II
Helper II

Calculation of weight of month within quarter and average of every month weight

This might be difficult to explain, but I will do my best.

 

I got four fiscal years of sales data, each fiscal year has 4 quarters and each quarter has 3 months. My management wants to see a chart where I compare the same month in the same quarter in different years. that's the easy part, but they want to see the weight each individual month had in the quarter, so the weight can be also compared and an average of each month group. So we can see whether the forecast is off/on average and be able to spot outliers through time.

The graph I need to build looks like this:

the orange bar is the weight of each individual month within their quarter and there's a calculation for the average of the month thru the fiscal years. 

Chava1881_0-1653503030015.png

The data table looks like this (shorten version) 

MonthSalesQuarterMonth #Fiscal Year
Nov-17         143,984Q112018
Dec-17         155,516Q122018
Jan-18         123,475Q132018
Nov-18         113,874Q112019
Dec-18         118,754Q122019
Jan-19         117,361Q132019
Nov-19         107,632Q112020
Dec-19         132,673Q122020
Jan-20         118,782Q132020
Nov-20           98,386Q112021
Dec-20         121,322Q122021
Jan-21           93,478Q132021
Nov-21         116,455Q112022
Dec-21         123,507Q122022
Jan-22           95,660Q132022

 

 



This is a mockup of how I got to calculate those numbers in the graph:

Chava1881_1-1653503165744.png

 

I have no idea how to create a measure that can give me the two things they are looking for, any suggestions or help would be greatly appreciated.

 

1 ACCEPTED SOLUTION

It's because the data in the report you provided has a finer granularity than the the mock-report I created. When the average of e.g. M10 is created, in your file the average is based on the rows instead of the sum of the month.

To achieve your desired outcome, change this part in [measure sales]

var _avg = CALCULATE(AVERAGE('Table'[Sales]),FILTER(ALL('Period'),Period[MonthGroup]=_mg))

 

to this 

var _avg = AVERAGEX(FILTER(ALL('Period'),Period[MonthGroup]=_mg),calculate(SUM(Total_Products_Database_Compute[Sales])))

 

View solution in original post

4 REPLIES 4
sturlaws
Resident Rockstar
Resident Rockstar

Hi, @Chava1881,

have a look at this mockup-report, I think it is almost what you are after:
sample report 

 

Cheers,
Sturla

If this post helps, then please consider Accepting it as the solution. Kudos are nice too.

Hello @sturlaws ,
it's almost perfect, and I really appreciate it! the only thing that is happening and I don't understand why the measure for the sales is not running the average for the monthgroup. It does show instead another calculation I couldn't decipher.

See screenshot below and link with PBIX

PBIX

Chava1881_0-1653594415662.png

I REALLY REALLY APPRECIATE YOUR HELP!!

It's because the data in the report you provided has a finer granularity than the the mock-report I created. When the average of e.g. M10 is created, in your file the average is based on the rows instead of the sum of the month.

To achieve your desired outcome, change this part in [measure sales]

var _avg = CALCULATE(AVERAGE('Table'[Sales]),FILTER(ALL('Period'),Period[MonthGroup]=_mg))

 

to this 

var _avg = AVERAGEX(FILTER(ALL('Period'),Period[MonthGroup]=_mg),calculate(SUM(Total_Products_Database_Compute[Sales])))

 

I have no words to be able to express how grateful I am to you, people like you make this community amazing!
thank you very much!!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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