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
thesweetp
Regular Visitor

How to calculate average on visual (filtered or sliced) - newbie

Hi everyone

Sorry total newbie question but I can't figure it out and couldn't find anything simple for this issue.

I would like to calculate (weighted) Average Price per Unit, of whatever is filtered or sliced and shown in the visual table.

However, it is giving me an average of everything not shown in this table.

How can I calculate this number?  Do I need a new measure?  

 

thesweetp_0-1624376642494.png

 

 

 

Thanks!

 

7 REPLIES 7
v-xulin-mstf
Community Support
Community Support

Hi @thesweetp

 

Is your issue solved?

If the issue has been solved, please adopt the solution to help others.

If you still have some question, please don't hesitate to let me known.‌‌

 

Best Regards,

Link

 

Is that the answer you're looking for? If this post helps, then please consider Accept it as the solution. Really appreciate!

 

 

v-xulin-mstf
Community Support
Community Support

Hi @thesweetp

 

In general, you can do as:

vxulinmstf_0-1624517232533.png

And it will show as your expected output.

vxulinmstf_2-1624517406490.png

If not, please provide your sample data after removing sensitive information, i will check in my environment.

 

Best Regards,

Link

 

Is that the answer you're looking for? If this post helps, then please consider Accept it as the solution. Really appreciate!

 

thesweetp
Regular Visitor

Thanks but it didn't work.  (according to my expectations)

The second column is using your formula.

I would expect 1847.63.

I tried to unsummarize and it showed me some more lines, but the calculated average remained the same.

thesweetp_0-1624393876158.png

Unsummarized Price per unit:

thesweetp_1-1624394082342.png

 

 

Anonymous
Not applicable

Is the price per unit column a measure or default summarization? If it's summarized, is it summarized as sum or average?

 

In this first table (Price per Unit) - is summarized as an AVERAGE 

The AveragePrice1 is a measure.

thesweetp_0-1624451799406.png

In this second column, it is unsummarized.

 

Unsummarized Price per unit:

thesweetp_1-1624451799423.png

 

I looked into my original data, and the $2209.65 is correct average of all the CPUs.

However, on the table, I only want it to average what is selected.

 

Thanks!

Anonymous
Not applicable

Ok, got it. It is weird that since you are using the default summarization, total is displayed as for all. Is it possible for you to share your pbix file?

 

Anonymous
Not applicable

You will need to modify your measure to CALCULATE(Average(PricePerUnit), ALLSELECTED(TableOrColumn)).

ALLSELECTED modifies the context to the only selected filters.

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.