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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
abukapsoun
Post Patron
Post Patron

Sum & average

 Hi Guys,

 

Need your support please,

 

I have the following dataset

 

for each of the day: I want to Sum people based on city, then i want to average the city based on flag. 

so Ger = average (msc1 (6+2) +msc2 (12+15))

appreciate if you can help me with the right measure to use. 

DateFlagCityPeople
11novmsc1ger6
11novmsc1ger2
11novmsc1it89
11novmsc1it12
11novmsc2ger12
11novmsc2ger15
12novmsc2it155
    
1 ACCEPTED SOLUTION

Download the PBI file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

7 REPLIES 7
Anonymous
Not applicable

Hi @abukapsoun ,

Please try below steps:

1. below is my test table

Table:

vbinbinyumsft_0-1668415793512.png

Table2:

create with below dax formula:

Table 2 = VALUES('Table'[City])

 

vbinbinyumsft_1-1668415812862.png

2. create a measure with below dax formula

Measure =
VAR cur_city =
    SELECTEDVALUE ( 'Table 2'[City] )
VAR tmp1 =
    FILTER ( ALL ( 'Table' ), [City] = cur_city )
VAR tmp2 =
    SUMMARIZE (
        tmp1,
        'Table'[Date],
        'Table'[City],
        'Table'[Flag],
        "Sum", SUM ( 'Table'[People] )
    )
RETURN
    AVERAGEX ( tmp2, [Sum] )

3. add a slicer with Table2, add a card visual with above measure

Animation14.gif

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_ Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Didn't really work with me 😞 

Can you please check the following post, I have included the dataset I am working on. I would really appreciate if you can have a look please.

https://community.powerbi.com/t5/Desktop/Matrix-with-different-level/m-p/2902152#M997246

 

Thanks,

Ashish_Mathur
Super User
Super User

Hi,

This measure works

Measure = AVERAGEX(VALUES(Data[Flag]),[Total])

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi @Ashish_Mathur 

 

What is the "Total" measure you have created? I can see it in your screenshot but not in the formula

 

Thank you

Download the PBI file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Greg_Deckler
Community Champion
Community Champion

@abukapsoun Try:

Measure = AVERAGEX(SUMMARIZE('Table',[Date],[City],"__Sum",SUM('Table'[People]),[__Sum])


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Hi Greg,

 

It didn't work, it seems there is a syntax error

I am getting the following: 

Too few arguments were passed to the AVERAGEX function. The minimum argument count for the function is 2.

As well I got error under: 

[__Sum]

Can you maybe send me a pbix for it? 

Helpful resources

Announcements
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.