cancel
Showing results for
Did you mean:
Helper I

How to calculate average based on filters selected on the page?

Hi,

I have a created a page in power bi that shows count of items sold to different customers in a table visual. With that I also have two slicer visuals - One which shows the years and second which shows the months. So now I wanted to calculate average based on the options selected on slicer.

For eg- If I choose Jan, Feb ,March then I want the average count of itmes sold to customer A,B ,C etc in these three months. Whereas, if I select Jan, Feb,March,April then I want the average count of itmes sold to customer A,B ,C etc in these four months. So basically it should take the items sold in each month for each customer and then divide the total by no of months selected (which would be subject to change as it depends on what months we choose).

Is there any way to achieve this? Any help would be appreciated!

1 ACCEPTED SOLUTION
Community Support

Hi @anchal5335,

Assume sample data looks like below:

You can create a measure:

Measure = var countitem=CALCULATE(COUNT('Table1'[Item]),FILTER(ALLSELECTED('Table1'),'Table1'[Customer]=MAX('Table1'[Customer])))
var countmonth=COUNTROWS(FILTERS(Table1[Month]))
return
DIVIDE(countitem,countmonth)

See attached pbix file.

Best Regards,
Qiuyun Yu

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
4 REPLIES 4
Community Support

Hi @anchal5335,

Assume sample data looks like below:

You can create a measure:

Measure = var countitem=CALCULATE(COUNT('Table1'[Item]),FILTER(ALLSELECTED('Table1'),'Table1'[Customer]=MAX('Table1'[Customer])))
var countmonth=COUNTROWS(FILTERS(Table1[Month]))
return
DIVIDE(countitem,countmonth)

See attached pbix file.

Best Regards,
Qiuyun Yu

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Helper I

Your solution was helpful but can you please explain me why you took max function? I am still unable to understand that step!

Helper I

Thanks @v-qiuyu-msft! This was helful!

Frequent Visitor

Announcements