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
Clara
Advocate II
Advocate II

Average/goal line on column chart, calculate with multiple filters

Hey everyone! I need your help. This is what I'm trying to achieve:
avgchart.PNG

In this case, the Y axis represents values and the X axis represents the store units in a chain.

 

My query looks sort of like this (except it includes many more months than just January 2018):

UnitDateItemValueType
A01/01/2018Total profits2600000Revenue
B01/01/2018Total profits2000000Revenue
C01/01/2018Total profits2300000Revenue
D01/01/2018Total profits3600000Revenue
E01/01/2018Total profits2300000Revenue
F01/01/2018Total profits2500000Revenue
G01/01/2018Total profits2100000Revenue
A01/01/2018Materials928663Expenses
B01/01/2018Materials500099Expenses
C01/01/2018Materials771053Expenses
D01/01/2018Materials773643Expenses
E01/01/2018Materials665997Expenses
F01/01/2018Materials905812Expenses
G01/01/2018Materials704711Expenses
A01/01/2018Taxes244094Expenses
B01/01/2018Taxes286262Expenses
C01/01/2018Taxes165851Expenses
D01/01/2018Taxes290773Expenses
E01/01/2018Taxes285362Expenses
F01/01/2018Taxes133670Expenses
G01/01/2018Taxes202245Expenses

 

In my report, I want to give the user the option to sort between Revenue and Expenses, keeping the same visuals. In the case of this chart, my report is filtered by Type = Revenue and Date = January 2018. I would like the chart to display a horizontal line corresponding to the average of all Revenue (meaning, average of "Total Profits") for the month of January. Is there any easy way to obtain this? I've tried many solutions but the average value always comes up wrong. I would love some fresh opinions.

 

P.S.: This query I've "sampled" above has already been filtered. The "Total Profits" values, for example, are actually the sum of many smaller values which have been hidden since they do not matter to the report at hand.

1 ACCEPTED SOLUTION
dedelman_clng
Community Champion
Community Champion

Hi @Clara

 

You can use a combo column/line chart, and for the line value you are going to compute the average across all units

 

Average Across All = CALCULATE(AVERAGE(Financials[Value]), ALL(Financials[Unit]))
//NOTE - if the number of units on the axis may change due to a slicer, change ALL to ALLSELECTED

Capture.PNG

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Hope this helps

David

View solution in original post

8 REPLIES 8
dedelman_clng
Community Champion
Community Champion

Hi @Clara

 

You can use a combo column/line chart, and for the line value you are going to compute the average across all units

 

Average Across All = CALCULATE(AVERAGE(Financials[Value]), ALL(Financials[Unit]))
//NOTE - if the number of units on the axis may change due to a slicer, change ALL to ALLSELECTED

Capture.PNG

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Hope this helps

David

Thanks for the reply, David! Unfortunately I'm getting a different result:

 

3.PNG

I wish I knew what I was doing wrong 😞

Can you share how your chart is built and how your specific measures are coded? Also your data model if there are multiple tables involved.

 

Capture.PNG

chart.PNGdb2.PNG

Here you go. (I had to filter some stuff out but I hope it will still make sense.)

Vvelarde
Community Champion
Community Champion

@Clara

 

Hi, AVGGrupo should be a Measure not a calculated column.

 

Regards

 

Victor

 

 




Lima - Peru

Thanks for the reply, Victor! Unfortunately trying it with a measure got me the same results as before... it shows the correct average in a card visual, for example, but in the chart it varies along the x axis.

Hi @Clara -

 

The field inside ALLSELECTED should be the same field as is on your X-axis.  From the look of it, your X-axis is "Loja", but you are averaging over all selected Unidade.  Either Unidade needs to be the X axis or Loja needs to go inside ALLSELECTED.

 

Hope this helps

David

Oops, you're right! My data has dozens of fields so I ended up getting them all mixed up, haha. Thanks!

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.