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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
A22MATIC
Frequent Visitor

Compute Average Cost in Power BI (Total Actuals / Count D Sites)

Hello,

 

I'm new to Power BI. The forums have been beneficial. I have encountered an issue that I have been unable to find a clear answer for or resolve.

I am trying to calculate the Average Spend $ for the total Count D Sites 10 (Total Actuals by Site / Total Count D of Sites). Can anyone assist or point me in the right direction? Thanks.

Picture1.png

1 ACCEPTED SOLUTION

I looked at the file, but I don’t quite understand what you want to do. If you use the filter in the top right corner of the canvas, it calculates the average for the selected project, right? Are you asking for the overall average regardless of the project selected?

You can achieve this with the following formulas:

 

Average Acts by Total Sites = 
VAR _Numerator = CALCULATE(SUM( 'Table112'[Actuals] ), ALL(Table112[Proj Def & Name]))
VAR _Denominator = 
CALCULATE(
    DISTINCTCOUNT( 'Table112'[Site]), ALL()
)
VAR _Result = 
DIVIDE(_Numerator,_Denominator,0)
RETURN
_Result

Or

Average Acts by Total Sites = 
VAR _Numerator = CALCULATE(SUM( 'Table112'[Actuals] ), ALL(Table112))
VAR _Denominator = 
CALCULATE(
    DISTINCTCOUNT( 'Table112'[Site]), ALL()
)
VAR _Result = 
DIVIDE(_Numerator,_Denominator,0)
RETURN
_Result

Oh I think maybe I understood what you want to do, try this and let me know:

 

Average Acts by Total Sites = 
VAR _Numerator = SUM( 'Table112'[Actuals] )
VAR _Denominator = 
CALCULATE(
    DISTINCTCOUNT( 'Table112'[Site]), ALLSELECTED()
)
VAR _Result = 
DIVIDE(_Numerator,_Denominator,0)
RETURN
_Result

View solution in original post

12 REPLIES 12
sanalytics
Super User
Super User

@A22MATIC 
Please use below code for your measure

Average Acts by Total Sites = 
VAR _Numerator = SUM( 'Table'[Total Actuals - Convention Spend] )
VAR _Denominator = 
CALCULATE(
    DISTINCTCOUNT( 'Table'[Site Number]), ALL()
)
VAR _Result = 
DIVIDE(_Numerator,_Denominator,0)
RETURN
_Result


below screenshot

sanalytics_0-1756807467424.png

 

Attached pbix file for your reference

Hope it hleps

 

Regards

sanalytics

Hello, Thanks for the response.

Unfortunately, that did not work. I've tried to include all the screenshots below. I thought maybe it's the data format (General vs. Whole Number). Not sure why it's not working. I don't see a way to attach the Power BI file, but if there's a way, please let me know.

A22MATIC_1-1756818639976.png

A22MATIC_2-1756818676030.png

 

A22MATIC_4-1756819017473.png

 

 

A22MATIC_3-1756818980215.png

A22MATIC_5-1756819084887.png

A22MATIC_6-1756819166042.png

A22MATIC_7-1756819173165.png

 

 

@A22MATIC Please share some dummy data along with your Power BI model. It will help us to work on..

Regards

sanalytics

Thanks. I see the issue. You are correct. The formula works. Do you know how to make it work with a slicer? My end users will filter on their Project, and will need to see the averages that way.

Your formula works, but I have a slicer, and when it's selected, the Average for Count D isn't working. I'm struggling trying to attach the Power BI file. Can you please let me know how I can do that?

bhanu_gautam
Super User
Super User

@A22MATIC 

Create a Measure for Total Spend:

Go to the "Modeling" tab.
Click on "New Measure".
Enter the following DAX formula to calculate the total spend

Total Spend = SUM('YourTableName'[Total Actuals - Convention Spend])

Then one for

Count of Distinct Sites = DISTINCTCOUNT('YourTableName'[Site Number])

 

And last for average

Average Spend per Site = [Total Spend] / [Count of Distinct Sites]




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Hello, Thanks for the response.

Unfortunately, that did not work.

A22MATIC_0-1756819512552.png

A22MATIC_1-1756819533082.png

A22MATIC_2-1756819573700.png

 

Hey @A22MATIC ,

why are you saying it's not working?
Sum of ACTS = 27637816

Number of sites= 250

Average= 27637816/250=110551

Do you want to display the same average in all the rows? Regardless of the site in the current row?

You are correct. The formula works. Do you know how to make it work with a slicer? My end users will filter on their Project, and will need to see the averages that way.

The issue is I have a slicer, and when it's selected, the Average for Count D isn't working. I'm struggling trying to attach the Power BI file. Can you please let me know how I can do that?

I looked at the file, but I don’t quite understand what you want to do. If you use the filter in the top right corner of the canvas, it calculates the average for the selected project, right? Are you asking for the overall average regardless of the project selected?

You can achieve this with the following formulas:

 

Average Acts by Total Sites = 
VAR _Numerator = CALCULATE(SUM( 'Table112'[Actuals] ), ALL(Table112[Proj Def & Name]))
VAR _Denominator = 
CALCULATE(
    DISTINCTCOUNT( 'Table112'[Site]), ALL()
)
VAR _Result = 
DIVIDE(_Numerator,_Denominator,0)
RETURN
_Result

Or

Average Acts by Total Sites = 
VAR _Numerator = CALCULATE(SUM( 'Table112'[Actuals] ), ALL(Table112))
VAR _Denominator = 
CALCULATE(
    DISTINCTCOUNT( 'Table112'[Site]), ALL()
)
VAR _Result = 
DIVIDE(_Numerator,_Denominator,0)
RETURN
_Result

Oh I think maybe I understood what you want to do, try this and let me know:

 

Average Acts by Total Sites = 
VAR _Numerator = SUM( 'Table112'[Actuals] )
VAR _Denominator = 
CALCULATE(
    DISTINCTCOUNT( 'Table112'[Site]), ALLSELECTED()
)
VAR _Result = 
DIVIDE(_Numerator,_Denominator,0)
RETURN
_Result

YES!! That is precisely what I'm trying to do!!

So sorry it took so long, and thank you for your patience with this newcomer!

Average Acts by Total Sites = 
VAR _Numerator = SUM( 'Table112'[Actuals] )
VAR _Denominator = 
CALCULATE(
    DISTINCTCOUNT( 'Table112'[Site]), ALLSELECTED()
)
VAR _Result = 
DIVIDE(_Numerator,_Denominator,0)
RETURN
_Result


 

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.