cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
rgadbois
Frequent Visitor

Incorrect Avg

Hi,

 

I am attempting to calculate an measure for an average based on 2 criteria within separate columns. I want to filter by position, and by day code as seen below. I want to filter by position "D" and day code "Game". The result I expect is 340, which is also the average shown in PowerQuery when filtering rows by these 2 criteria, though the measure I am using shows "345". Any assistance with this would be great. Thank you!

 

Note - I have tried numerous iterations of CALCULATE, with these 2 filters, COUNTROWS, and similar functions but all produce the exact same result, which is incorrect. Any additional insight into how DAX is calculating this average, whereas PowerQuery shows the value I expect being different from the calculation, it would be greatly appreciated!

 

_Forwards Game PL =
CALCULATE(AVERAGE(
    Catapult[PL]),
    FILTER(ALL(Catapult),Catapult[Day Code] = "Game" && Catapult[Position Name] = "F"
    )
 )

Position

PL

Day Code

D310Game
D313Game
D326Game
D403Game
D332Game
D382Game
D332Game
D370Game
D367Game
D348Game
D321Game
D394Game
D329Game
D325Game
D327Game
D294Game
D339Game
D341Game
D315Game
D300Game
D375Game
D229Game
D357Game
D319Game
D375Game
D326Game
D421Game
D340Game
 
EDIT: I have also just tried the average for the entire column without any filters and get an incorrect value. Why does PowerBI do this??? This is extremly frustrating as I am beginning to question data integrity from PowerBi. Thank you!
1 ACCEPTED SOLUTION
tackytechtom
Super User
Super User

Hi @rgadbois ,

 

I used your measure as posted in your question. Note, I changed Position from "F" to "D" because "D" was the only value that you provided in your sample data:

tomfox_0-1665162016062.png

 

 

As you can see, I get the 340. Could it be that you just used the wrong letter? Otherwise, I think your DAX looks good 🙂 Here another way of writing it:

 

tomfox_1-1665162172309.png

_Forwards Game PL = 
CALCULATE ( AVERAGE ( tabell[PL] ), tabell[Day Code] = "Game" && tabell[Position] = "D" )

 

 

Hope this helps!

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

2 REPLIES 2
tackytechtom
Super User
Super User

Hi @rgadbois ,

 

I used your measure as posted in your question. Note, I changed Position from "F" to "D" because "D" was the only value that you provided in your sample data:

tomfox_0-1665162016062.png

 

 

As you can see, I get the 340. Could it be that you just used the wrong letter? Otherwise, I think your DAX looks good 🙂 Here another way of writing it:

 

tomfox_1-1665162172309.png

_Forwards Game PL = 
CALCULATE ( AVERAGE ( tabell[PL] ), tabell[Day Code] = "Game" && tabell[Position] = "D" )

 

 

Hope this helps!

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thank you! I knew I wasn't crazy. Sorry for the error on that letter, I am doing this for both forwards and defensemen. I had ensured I entered the correct letter in PowerBI for this instance as well. I also just tried taking the average for the entire column with no filters and saw that it was also incorrect. Any possible insight as to why this may be the case?

 

NOTE - I do get the correct value on a blank page.... but when I add this measure as a card on a page with visuals, but NO page filters, the value is incorrect.

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors