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
Anonymous
Not applicable

Calculate average with gaps of data

Hello ,

I have a fact table that contains this two value 

MR_Robot92_0-1645480089684.png

i create a measure that return the Qty on hand through the year as below the result of my measure:

 

MR_Robot92_1-1645480134991.png

Now , i want to calculate the average of Qty on hand (previous result) .

 

I create a new measure avg , that call the previous measure like as below : 

 

average of Qty on hand = averagex('Fact table',[Qty on hand])

 

As below the result : 

MR_Robot92_2-1645480458947.png

 

 

The result that i get it isn't what i want because i get only that average (238+298)/2 

While  i want to have an average or all the row  ((238*7)+(298*5))/12

 

FYI : I want also that measure work with another context for example if i choose another dimension 

 

Any idea how can i do that ? 

 

Thanks for help !! 

6 REPLIES 6
MFelix
Super User
Super User

Hi @Anonymous ,

 

You need to make the average based on the months values somethign similar to:

average of Qty on hand = averagex(Values('Fact table'[Month]),[Qty on hand])

Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Anonymous
Not applicable

@MFelix  the granularity in my fact table is date like as below :

MR_Robot92_0-1645629570481.png

 

But what if i want to work for all the level , i need to create all measure for different level ?

i will have a lot of measure ...... There are any solution to optimize that ? 

 

Thanks 

Hi @Anonymous ,

 

Has the problem been solved? If the problem still exists, could you provide a sample pbix for us to do more tests.


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

Anonymous
Not applicable

Hi @V-lianl-msft 
Thanks for the reply.
the model is based on SSAS tabular model i don't think so the pbix can help you because i use a live connection to the cube.
Well, the proposed solution by @MFelix  worked only with month but when i use another level of date the average doesn't work correctly

for example if i want to analyse the Average of qty on hand by week or Quarter or day ? 
i need to create anothers measure for that ? like as below : 

 

average of Qty on hand Week = averagex(Values(Calendar[Week]),[Qty on hand])
average of Qty on hand Quarter = averagex(Values(Calendar[Quarter]),[Qty on hand])

 

 

I will have a lot of measure because i need to create average for 10 measure and if i want to cover Month , Week and Quarter i will have 30 measures for average .
There are anoter solution to optimize that ? 

Hi @Anonymous ,

 

In this case you need to use calculation groups with the same sintax for each of the periods quarter, month and week and using the calculation groups you are abble to use it whit any measures at once (in this case 30).

 

https://www.sqlbi.com/blog/marco/2020/07/15/creating-calculation-groups-in-power-bi-desktop/


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Hi @Anonymous ,

 

How is your model setup? do you have a calendar table? 

 

You create measures in order to not have to create one for each level of course this depends on the result you want to achieve.

 

Can you please share a mockup data or sample of your PBIX file. You can use a onedrive, google drive, we transfer or similar link to upload your files.

If the information is sensitive please share it trough private message.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



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