cancel
Showing results for
Did you mean:

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a \$100 discount. Register Now

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 D 310 Game D 313 Game D 326 Game D 403 Game D 332 Game D 382 Game D 332 Game D 370 Game D 367 Game D 348 Game D 321 Game D 394 Game D 329 Game D 325 Game D 327 Game D 294 Game D 339 Game D 341 Game D 315 Game D 300 Game D 375 Game D 229 Game D 357 Game D 319 Game D 375 Game D 326 Game D 421 Game D 340 Game

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
Super User

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:

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:

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

Hope this helps!

 Also happily accepting Kudos 🙂

 Feel free to connect with me on LinkedIn!

 #proudtobeasuperuser

2 REPLIES 2
Super User

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:

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:

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

Hope this helps!

 Also happily accepting Kudos 🙂

 Feel free to connect with me on LinkedIn!

 #proudtobeasuperuser

Frequent Visitor

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.

Announcements

#### Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

#### Power BI Monthly Update - February 2024

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

#### Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

#### Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors
Top Kudoed Authors