Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

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➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

July 2024 Power BI Update

Power BI Monthly Update - July 2024

Check out the July 2024 Power BI update to learn about new features.

July Newsletter

Fabric Community Update - July 2024

Find out what's new and trending in the Fabric Community.