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
abalgir
Helper I
Helper I

Filter on a table where Total Cost for a group is grater than the average cost of the same group

Hello,

I have 2 tables :

A table that gives the average cost per country

table avg.PNG

 

another one that gives the total cost per country

 

table cost.PNG

I would like to create a visual that lists only the countries where Total Cost > Average Cost i.e:

FRANCE and USA

 

What is the best way to do that for a very large table?

Thank you 

Gerard

 

 

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@abalgir ,

Try something like this - sumx(filter(summarize(Country[Country], "_Avg",[Avg Cost],"_sum",[Total Cost]), [_sum]>[_avg]),[_sum])

 

You can replace [_sum] with [_avg]

 

View solution in original post

6 REPLIES 6
v-lid-msft
Community Support
Community Support

Hi @abalgir ,

 

We can try to create a measure, then put it into visual filter and set condition as "is 1" to meet your requirement:

 

 

Visual Control =
IF ( [TOTAL COST] > [AVG COST], 1, -1 )

 


If it doesn't meet your requirement, kindly share your sample data and expected result to me if you don't have any Confidential Information. Please upload your files to One Drive For Business and share the link here.


Best regards,

 

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
amitchandak
Super User
Super User

@abalgir ,

Try something like this - sumx(filter(summarize(Country[Country], "_Avg",[Avg Cost],"_sum",[Total Cost]), [_sum]>[_avg]),[_sum])

 

You can replace [_sum] with [_avg]

 

danextian
Super User
Super User

hI @abalgir ,

Are those tables two separate tables in your data model or are they from the same table but shown in separate visuals?

The formula below works if the data is coming from the same table.

Country measure =
SUMX (
    VALUES ( 'Table'[Country] ),
    VAR __TOTAL =
        CALCULATE (
            SUM ( 'Table'[Total Cost] ),
            ALLEXCEPT ( 'Table', 'Table'[Country] )
        )
    VAR __AVERAGE =
        CALCULATE (
            AVERAGE ( 'Table'[Total Cost] ),
            ALLEXCEPT ( 'Table', 'Table'[Country] )
        )
    RETURN
        IF ( __TOTAL > __AVERAGE, __TOTAL )
)

 










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


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Hi,

Thank you for the response, these are 2 separate tables

 

I tried on the same table and both methods work.

Thank you

I tested on the same table and both methods work.

Thanks

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.