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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
dfox09
Helper III
Helper III

how to average revenue at a higher level

I am writing this in the hopes that the Aces of the community may have encountered something like this before. I have a table that has producer, client and revenue (among other fields). The revenue is at the client level. Each producer will have multiple clients. It's no problem summing up the revenue to the producer level but what I can't figure out is how to average the revenue at the producer level. When I use a formula like this: 

Producer_Rev = Calculate(
AVERAGE('TBL_Actuals'[Producer Revenue]),
ADDCOLUMNS('TBL_Actuals',"Producer",'TBL_Actuals'[ProducerName])), it averages the revenue for all of the clients within a producer. What I would like to see would be an average of the producer revenue across x number of periods (in my case,months). 
Thank you!
Don
18 REPLIES 18
lbendlin
Super User
Super User

Without seeing your sampe data I would think that AverageX() is what you are looking for.

 

Here is a sample of the table. "BeginDate' is from a DimAccounting table that is joined by AcctPD. I included multiple months to see if there is a way to show how to average across months. My full data set goes back to 04/01/2019. Here is a formula that I was not able to get to work: 

Foward Forecast =
CALCULATE(a
AVERAGEX(
'Measures Table','Measures Table'[Producer_Rev]),
DATESBETWEEN('DimAccountingPeriod'[BeginDate],
DATEADD(DimAccountingPeriod[Today],-11,MONTH),
DATE(2020, 04,30)))

"Producer_Rev" is 

Producer_Rev = Calculate(
AVERAGE('TBL_Actuals'[Producer Revenue]),
ADDCOLUMNS('TBL_Actuals',"Producer",'TBL_Actuals'[ProducerName]))
BeginDateAcctPDProducerNameParent ClientProducer Revenue
5/1/2020202005Mickey MantleBarbara Bufkin & Michael Wybar($6.44)
5/1/2020202005Mickey MantleDoug Dirks$78.07
5/1/2020202005Mickey MantleDouglas & Sandra Johnson$71.10
5/1/2020202005Mickey MantleDouglas and Virginia Ware$161.84
5/1/2020202005Mickey MantleFelix Augusto & Elan Sasso$1,829.53
5/1/2020202005Mickey MantleGeorge & Joan Lange$411.38
5/1/2020202005Mickey MantleGeorge and Martha Richards$90.31
5/1/2020202005Mickey MantleJames Gearen($5.30)
5/1/2020202005Mickey MantleJeff & Erin Prendergast$839.06
5/1/2020202005Mickey MantleKathie and Wayne Volland$699.16
5/1/2020202005Mickey MantleKathy Richter & Lisa Gladstone$77.41
5/1/2020202005Mickey MantleKenneth & Chaumarie Chastain$1,044.01
5/1/2020202005Mickey MantleKyle & Kate Watson($482.38)
5/1/2020202005Mickey MantleLawrence & Caroline Heard$15.93
5/1/2020202005Mickey MantleLois B. Pope$2,703.22
5/1/2020202005Mickey MantleMichael McGowan$682.45
5/1/2020202005Mickey MantleRichard & Helen McCourt$1,639.45
5/1/2020202005Mickey MantleRobert and Melanie Stanek($73.88)
5/1/2020202005Mickey MantleRodney & Lisa Ragland$582.65
5/1/2020202005Mickey MantleSamuel & Sarah Cooper$84.96
5/1/2020202005Mickey MantleScott & Chellye Tanberg$71.10
5/1/2020202005Mickey MantleScott Ellington$1,433.52
5/1/2020202005Mickey MantleSteven and Debra Rowley$4,801.20
5/1/2020202005JJ AbramsAscend Athol RE LLC$7,403.60
5/1/2020202005JJ AbramsBrookhaven Science Associates$6,931.83
5/1/2020202005JJ AbramsMarshall, Dennehey, Warner, Coleman & Goggin$5,808.10
5/1/2020202005JJ AbramsVerus Claims Services, LLC$86.10
5/1/2020202005JJ AbramsWeill Cornell Medicine$45,371.27
5/1/2020202005JJ AbramsYeshiva University$5,382.54
5/1/2020202005Bailey,GeorgeAura$16,618.92
5/1/2020202005Bailey,GeorgeBilly Casper Golf, LLC$18,123.60
5/1/2020202005Bailey,GeorgeCampaign Monitor$5,240.46
5/1/2020202005Bailey,GeorgeChoice Hotels International, Inc.-BEN$8,905.88
5/1/2020202005Bailey,GeorgeCoastal Sunbelt Produce$1,871.22
5/1/2020202005Bailey,GeorgeCommunication Technologies Inc$269.28
5/1/2020202005Bailey,GeorgeCrews Enterprises, LLC$8,434.42
5/1/2020202005Bailey,GeorgeCSSI, Inc.$6,181.29
5/1/2020202005Bailey,GeorgeEmergent Biosolutions Inc.$15,271.41
5/1/2020202005Bailey,GeorgeEVAPCO$10,940.64
5/1/2020202005Bailey,GeorgeFive Guys Holdings, Inc.$2,891.97
5/1/2020202005Bailey,GeorgeLockton - Dunning$666.75
5/1/2020202005Bailey,GeorgeLockton Atlanta (Hartford) - LOCAT15$13,240.75
5/1/2020202005Bailey,GeorgeLockton Dunning (Hartford) - LOCDU21$1,409.59
5/1/2020202005Bailey,GeorgeLockton KC - LOCCO14$5,173.12
5/1/2020202005Bailey,GeorgeMCI, USA$7,340.25
5/1/2020202005Bailey,GeorgeMPR Associates$1,445.13
5/1/2020202005Bailey,GeorgeNash Holdings LLC$7,604.98
5/1/2020202005Bailey,GeorgePhillips Corporation$15,438.58
5/1/2020202005Bailey,GeorgeREGENXBIO, Inc.$1,494.94
5/1/2020202005Bailey,GeorgeSalient CRGT($196.34)
5/1/2020202005Bailey,GeorgeTechSource$4,225.51
5/1/2020202005Frank CapraCarlyle Realty Partners LP$462,250.11
5/1/2020202005Frank CapraDuke Realty Corporation$652.95
5/1/2020202005Frank CapraGMH Associates, Inc$7,872.25
5/1/2020202005Frank CapraMad Happy, LLC$0.00
5/1/2020202005Frank CapraMerion Realty Management, LLC$3,668.18
5/1/2020202005Frank CapraMMA Capital Holdings, Inc.$27,368.25
5/1/2020202005Frank CapraNahla Capital$6,250.00
5/1/2020202005Frank CapraPulse EFT Association, LP$0.00
5/1/2020202005Frank CapraSunrise Senior Living, LLC$29.21
5/1/2020202005Frank CapraTruNorth Mechanical, LLC$321.15
5/1/2020202005Frank CapraWoodfield Investment Company, LLC$7,713.40

See if this helps for the average producer revenue.

 

 

Producer_Rev = DIVIDE(sum(TBL_Actuals[Producer Revenue]),DISTINCTCOUNT(TBL_Actuals[ProducerName]))

 

 

Thank you for your reply. When I plug that formula in, I get the same amount as if I was using another formula. Here is the other formula.  

Production = CALCULATE(sum(TBL_Actuals[Producer Revenue])) which yeilds the same result. Where it gets hazy for me is trying to do an average of that revenue.
Here is the formula that I tried but I can't get it to work - 
Foward Forecast =
CALCULATE(
AVERAGEX(
'Measures Table','Measures Table'[Producer_Rev]),
DATESBETWEEN('DimAccountingPeriod'[BeginDate],
DATEADD(DimAccountingPeriod[Today],-11,MONTH),
DATE(2020, 04,30)))
 . When I put it in place I get the following message: 

MdxScript(Model) (127, 13) Calculation error in measure 'Measures Table'[Foward Forecast]: Table 'Measures Table' cannot be used in computations because it does not have any columns.

Any suggestions?

The average across producers is a single number, in the totals. Are you expecting it to display next to each producer? If so, why?

 

lbendlin_0-1595361705293.png

 

Good question. What I'm trying to show would be a forward looking forecast based on the average of the producer revenue from the month (of the prior fiscal year) to the last month of the prior fiscal year, in my case, April, 2020. Our Fiscal year goes from May to April. Hence that crazy looking formula that i pasted in.  This might show something like this;

dfox09_0-1595364060595.png

I can do that formula in Excel but can't do it in dax or power query. I could use some help in that.

Don

That is a rather different ask from the original question. See if this thread can be of help

https://community.powerbi.com/t5/DAX-Commands-and-Tips/Rolling-12-Month-Average-result-used-to-Forec...

 

I read the post and like what you came up with for the rolling 12 month average. I was able to modify it, to a point, for my purposes. Wondering if you might be able to help me figure out how to calculate an average that averages monthly revenue(like in your other post) from the month that is the month after the month, that a producer is being forecasted for, up to the last month of the prior Fiscal Year. For example if Wayne is a Producer and we are trying to forecast August, 2020 then we would average the monthly revenue from September, 2019 through April, 2020 (The last month of the prior fiscal year). If we were to forecast September, it would be October, 2019 through April, 2020.

Much appreciated,

Don

Yes, all you need to do is change the EDATE() offsets.

 

'FactTable'[Day]>=EDATE(m,-12) && 'FactTable'[Day]<EDATE(m,0)),

 

I changed it slightly to add the edate for the second comparison. You would need to change the -12 and 0 accordingly.

Thank you for that suggestion. I will try it. In the meantime, here is what I did:

Foward Forecast =
var m = SELECTEDVALUE(DimAccountingPeriod[BeginDate])
var t = (m>TODAY())
var a = CALCULATE(SUM(TBL_Summarized_Actuals[Revenue]),DimAccountingPeriod[BeginDate]>EDATE(m,-12),DimAccountingPeriod[BeginDate]<=DATE(2020,04,30))
Return a/12
I hardcoded 4/30/2020 since I knew that, that would always be the end date of the particular forecasting period.
I am real close to, but still not matching what I have in Excel. For example;
Name                    ID         Month        Revenue      Budget           Forecast
Bailey,George271796/1/2019 $            126,293 $            176,295 $             -   lbendlin 
Bailey,George271797/1/2019 $            148,910 $            136,995 $             -   
Bailey,George271798/1/2019 $            133,568 $            158,566 $             -   
Bailey,George271799/1/2019 $            200,510 $            156,340 $             -   
Bailey,George2717910/1/2019 $            306,490 $            152,122 $             -   
Bailey,George2717911/1/2019 $            153,296 $            146,923 $             -   
Bailey,George2717912/1/2019 $            202,763 $            148,716 $             -   
Bailey,George271791/1/2020 $            191,809 $            139,800 $             -   
Bailey,George271792/1/2020 $            146,127 $            143,700 $             -   
Bailey,George271793/1/2020 $            222,464 $            143,700 $             -   
Bailey,George271794/1/2020 $            207,484 $            149,512 $             -   
Bailey,George271795/1/2020 $            152,592 $            179,863 $             -   
Bailey,George271796/1/2020 $            192,613 $            179,863 $  191,342 $  188,219
Bailey,George271797/1/2020 $              16,145 $            185,863 $  196,057 $  184,962
Bailey,George271798/1/2020  $            179,863 $  203,868 $  173,831
Bailey,George271799/1/2020  $            179,863 $  204,348 $  157,122
Bailey,George2717910/1/2020  $            192,363 $  187,324 $  131,581
Bailey,George2717911/1/2020  $            194,863 $  194,129 $  118,806
Bailey,George2717912/1/2020  $            194,863 $  191,971 $  101,910

Your numbers are closer to the Excel forecast than what I tried. I didn't quite follow what you meant by "changing the -12 and 0". Is there a way to set this up relative to the month being forecasted?

yes, that's what EDATE() does - it allows you to shift the month window around and change its size according to your requirements.

 

Note: the smaller the window the less reliable the forecast will be.

I think I am getting real close. Here is the modified formula:

Forward Forecast4 =
var m = SELECTEDVALUE(DimAccountingPeriod[BeginDate])
var t = (m>TODAY())
var i = DATEDIFF(m,Date(2020,04,30),MONTH)
var a = CALCULATE(SUM(TBL_Summarized_Actuals[Revenue]),DimAccountingPeriod[BeginDate]>EDATE(m,-i),DimAccountingPeriod[BeginDate]<=EDATE(m,0))
Return a/i
I think that the selected date will have to be the current month - 11 (months) and then, the calculation would be the average of the number of months between that date, whatever month that is, and 4/30/2020. I just don't know how to build that in to the formula.

Can you tell me why this formula doesn't work (besides what Power BI is saying) and how to correct it?

Forward Forecast5 =
var m = SELECTEDVALUE(DimAccountingPeriod[BeginDate])
var t = EDATE(m,-12)
var i = DATEDIFF(t,Date(2020,04,30),MONTH)
var a = CALCULATE(SUM(TBL_Summarized_Actuals[Revenue]),
DATESBETWEEN('DimAccountingPeriod','DimAccountingPeriod'[BeginDate] = t,'DimAccountingPeriod'[BeginDate] = m))
Return a/i
Power BI Error - DatesBetween and DatesInPeriod functions are only accepting date column reference as a first argument.

var a = CALCULATE(SUM(TBL_Summarized_Actuals[Revenue]),
DATESBETWEEN('DimAccountingPeriod', t, m))
 
DATESBETWEEN needs date values, not comparisons.

I had tried that solution before and PBI threw the error, "DatesBetween and DatesInPeriod functions are only accepting date column reference as a first argument."

For some reason, it doesn't accept a variable as a date.

Here is the whole formula:

Forward Forecast5 =
var m = SELECTEDVALUE(DimAccountingPeriod[BeginDate])
var t = EDATE(m,-12)
var i = DATEDIFF(t,Date(2020,04,30),MONTH)
var a = CALCULATE(SUM(TBL_Summarized_Actuals[Revenue]),
DATESBETWEEN('DimAccountingPeriod', t, m))
Return a/i

Doesn't sound like 'DimAccountingPeriod' is your Dates table ? Check the definition of DATESBETWEEN()

so I went back and looked and realized that DimAccounting is not a tru date table as there were gaps in BeginDate. I brought in a real date table, DimDate and started using that but I got a real interesting result when I used it.

It gave me slightly inflated forecasted revenue numbers through the current month (7/1/2020) but showed "infinity" everything forward.

Here is the formula:

Forward Forecast5 =
var m = SELECTEDVALUE(DimDate[StartOfMonthDate])
var t = EDATE(m,-12)
var i = DATEDIFF(t,Date(2020,04,30),MONTH)
var a = CALCULATE(SUM(TBL_Summarized_Actuals[Revenue]),
DATESBETWEEN('DimDate'[Date],t,m))
Return a/i
See anything strange?

Actually it is my Date table. BeginDate is datatype Date. is there something that I am not seeing?

As always, appreciate the help!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.