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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Incorrect Average Calculation

Hi everyone,

 

I am very new to Power BI (and definitely to DAX) and I can't seem to figure out where the error is, hope someone out there can help me out!

 

What I want to achieve, is getting an average per store, weighted by store visits. 

 

STORESSTORE VISITS
Store 13
Store 24
Store 36
Store 42

 

 

 

 STORE 1STORE 2STORE 3STORE 4

PRODUCT A

7574
PRODUCT B3168
PRODUCT C6455

 

So if we would go from this example, I would need to get following table:

 

 STORE 1STORE 2STORE 3STORE 4
PRODUCT A2,331,251,172
PRODUCT B10.2514
PRODUCT C210.832,5

 

I don't get this result just by calculating average, though. It seems that it only divides the number of products by the amount of store visits which was needed to find it.

 

So for example: If Product A was found 7 times in Store 1; in total there have been 3 store visits in Store 1; but Product A was found 7 times in only 2 store visits => It will divide 7/2.

 

Other things u might need to know:

  • Store Visits is a measure: First I Concatenate Adress & Date -> Separate Store Visit
  • Then I Distinctcount that calculated column.

 

  • I also have another Calculated Column to show the amount of store visits per store.
  • I tried putting everything in 1 measure 

 

The closest I've gotten so far is: 

AVERAGEX(
    KEEPFILTERS(VALUES('Data'[SeperateStorevisits])),
    CALCULATE(COUNTA('Data'[Product])) 
)
 
I am sure it has to be something really simple that I don't know about yet, but I know you guys can help me out!
 
Much appreciated!
 
Cheers,
Joris
1 ACCEPTED SOLUTION
Fowmy
Super User
Super User

@Anonymous 

Can you try this measure please:

Measure = 
DIVIDE(
    COUNT(DatalijstWinkelbezoek[Product Type]),
    CALCULATE(
        [#Storevisits],
        ALLSELECTED(DatalijstWinkelbezoek[Product Type])
    )
)

 

________________________

Did I answer your question? Mark this post as a solution, this will help others!.

Click on the Thumbs-Up icon on the right if you like this reply 🙂

YouTube, LinkedIn

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

5 REPLIES 5
Fowmy
Super User
Super User

@Anonymous 

Can you try this measure please:

Measure = 
DIVIDE(
    COUNT(DatalijstWinkelbezoek[Product Type]),
    CALCULATE(
        [#Storevisits],
        ALLSELECTED(DatalijstWinkelbezoek[Product Type])
    )
)

 

________________________

Did I answer your question? Mark this post as a solution, this will help others!.

Click on the Thumbs-Up icon on the right if you like this reply 🙂

YouTube, LinkedIn

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Anonymous
Not applicable

Thanks a lot! 
I feel like I've tried very similar techniques but never got it right, I knew it was going to be something simple..

 

harshnathani
Community Champion
Community Champion

HI @Anonymous ,

 

Not very clear.

Can you share a sample .pbix or sample data in text format.

 

Regards,

Harsh Nathani

Anonymous
Not applicable

Hey,

 

Okay I tried converting my data in sample data, hopefully, this makes it more clear. The data shown is limited, but I assume it should be enough to make my point. 

 

.pbix Sample File 

 

I added the needed tables for information:

 

- I want to calculate the average of times Product Type appears per Store, divided by the amount of Store Visits.

=>This way I want to have a sort of weighted average to compare how often a Product Type appears in each store.

 

- The way it calculates the average now: It doesn't divide the total times the Product Type appears, by the total amount of Store Visits, just by the amount of Store Visits whereby this Product Type was registered.

 

I hope this makes more sense now...

 

Thanks in advance, internet wizards!

lbendlin
Super User
Super User

Your sample tables are inconsistent with your explanation.  The first table shown seems to be an aggregate - we would need to see the raw data.  The second table hopefully is just a visual as well. If not then you MUST unpivot it before proceeding.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors