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
addaline
Helper I
Helper I

Company Average from filtered data

I have dug around the forums and have a general idea of what I should be doing to accomplish this, but I'm missing something, and hoping the hive mind can help.

 

I am trying to show the company average of a value on a card. I get the value in a table, and the table shows the average correctly when filtering by date, etc.

 

I need to get that average on a card.


Exmaple of table with average:

 

PR-Company-Average.png

 

 

I created a measure as follows:

 

---

CompanyAveragePR =
CALCULATE(
DIVIDE(
SUMX(FILTER(PerformanceRatio, PerformanceRatio[PerformanceRatio] <> 0),PerformanceRatio[PerformanceRatio]),
COUNTX(FILTER(PerformanceRatio, PerformanceRatio[Total] <> 0), PerformanceRatio[ReportedDate]),
0),
ALLSELECTED(PerformanceRatio),
PerformanceRatio[Total] <> 0,
PerformanceRatio[PerformanceRatio] <> 0
)

---


But, as noted in the in the above table, it's coming up with the wrong result, apparently taking everything into account.

 

Where am I going wrong?

 

Thanks,

 

Dion

1 ACCEPTED SOLUTION

@mahoneypat , @v-eachen-msft : Thank you for your replies.

 

Unfortunately neither result matched the Avg PR from the table, but in the course of working through your suggestions I think I found a result that works, using 3 Measures:

 

PRTotal = SUM(PerformanceRatio[PerformanceRatio])

 

DaysWorkedCount = COUNTA(PerformanceRatio[ReportedDate])

 

CompanyAverage = 
    CALCULATE(
    [PRTotal]/[DaysWorkedCount],
    ALLSELECTED(PerformanceRatio))

 

This matches the Avg PR displayed in the table, and adjusts along with the table based on the selected dates, people, etc. which it what I needed for the card.

 

Thank you.

View solution in original post

4 REPLIES 4
v-eachen-msft
Community Support
Community Support

Hi @addaline ,

 

Do you mean to get a measure which is like "Avg PR"?

You could use ALLEXCEPT() to get result of each name:

CompanyAveragePR =
CALCULATE (
    DIVIDE (
        SUMX (
            FILTER ( PerformanceRatio, PerformanceRatio[PerformanceRatio] <> 0 ),
            PerformanceRatio[PerformanceRatio]
        ),
        COUNTX (
            FILTER ( PerformanceRatio, PerformanceRatio[Total] <> 0 ),
            PerformanceRatio[ReportedDate]
        ),
        0
    ),
    ALLEXCEPT ( PerformanceRatio, PerformanceRatio[CrewLeaderName] ),
    PerformanceRatio[Total] <> 0,
    PerformanceRatio[PerformanceRatio] <> 0
)

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.

@mahoneypat , @v-eachen-msft : Thank you for your replies.

 

Unfortunately neither result matched the Avg PR from the table, but in the course of working through your suggestions I think I found a result that works, using 3 Measures:

 

PRTotal = SUM(PerformanceRatio[PerformanceRatio])

 

DaysWorkedCount = COUNTA(PerformanceRatio[ReportedDate])

 

CompanyAverage = 
    CALCULATE(
    [PRTotal]/[DaysWorkedCount],
    ALLSELECTED(PerformanceRatio))

 

This matches the Avg PR displayed in the table, and adjusts along with the table based on the selected dates, people, etc. which it what I needed for the card.

 

Thank you.

Hi @addaline ,

 

I am glad that you could find the solution. You could accept your own reply to close the topic.

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.
mahoneypat
Microsoft Employee
Microsoft Employee

Not sure I fully understand your issue but you could try a pattern like this to get your desired result.  I can't tell if the P.R. and Days Worked columns are columns or measures so here are both version.

 

If columns

CompanyAverage = SUMX(VALUES(Table[CrewLeaderName]), CALCULATE(DIVIDE(SUM(Table[P.R.]), SUM(Table[Days Worked]))))

If measures 

CompanyAverage = SUMX(VALUES(Table[CrewLeaderName]), DIVIDE([P.R.], [Days Worked]))

 

You can wrap the whole thing in CALCULATE( ... , ... <> 0, ...<>0) if needed.

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat

 





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

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


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.