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! Learn more

Reply
depple
Helper III
Helper III

Average based on total population

Hi,

 

I am trying to do something that is way out of my league, yet should I accomplish it, the output would be really powerful. It might be a trivial solution, but I might not be able to describe good enough what I am trying to do, but I will give it a shot.

 

In the visual table below each 0 indicates a Store with no sales of a Product Category. It is filtered, so the hundreds of other Store with sales in both Alfa and Bravo are not displayed.

 

 Product Category
StoreAlfaBravo
Store 1 0
Store 200
Store 30 
Store 4 0
Store 50 
Store 6  
Store 7 0
Store 8 0

 

I would like to make new visual table with the same dimensions and same output of Store, but where there are "0" in visual table above, I would like to display average sales (think sales lost. This average is calculated from all Store with sales, and I have a measure for this. But it is not working in this context, because when I involve Store in table, the average is calculated per Store.

 

1) How do I alter measure below to disregard the Store dimension of my data? There are other dimensions that I would like to keep, but not Store.

 
AvgSales = DIVIDE([Sales];'Data[Distribution])
 
2) How do I get my AvgSales in the visual table where the 0's are? Here is the measure for 0 sales:
 
ZeroSales = VAR StoresWithZeroProduct =
FILTER (
VALUES ( 'Data'[Store] );
NOT ISEMPTY ( FILTER ('Data';[Sales]=0 ))
)
RETURN
CALCULATE( [Sales]; KEEPFILTERS ( StoresWithZeroProduct))
 
I will really appreciate any input on this. If everything turns out the way I want, the visual table would look like this:
 
 Product Category
StoreAlfaBravo
Store 1 12
Store 29 
Store 39 
Store 4  
Store 59 
Store 6  
Store 7 12
Store 8 12
 
 

 /depple

2 REPLIES 2
yelsherif
Resolver IV
Resolver IV

First, for the average part:

use the CALCULATE function and ALL or ALLSELECTED as follows:

AvgSales = DIVIDE(CALCULATE([Sales],ALLSELECTED(Data));'Data[Distribution]))

Now for placing the average instead of zeros, you can use a measure in the table instead of the Sales column:

_Sales = if(SELECTEDVALUE(Data[Sales]) = 0, [AvgSales], SELECTEDVALUE(Data[Sales]))

 

It would be better if you share the pbix file so that I make sure the calculations are correct

Hi @yelsherif ,

 

Thank you for your suggestion.

I was just about to delete my post, as I managed - by extensive trial & failure - to come up with a working solution. Unfortunately I immediately struck a new problem, because my matrix's vertical sums is returning values that appear to be - if not - close to averages. I have never experienced that before, so I guess that I could have something to do with the extremely homemade measures. I will try your measures, surely they are better, and maybe that'll do the trick!

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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