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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

metrics that filter by Country and you get the values by OU

Hello 

 

i have requirement where when you select country then you should get the values of respective OU.

 

example: if in Europe OU you have 2 countries(Spain, France), if you select one of the countries then you should get the sum of 2countries i.e., sum of Europe OU.

 

please help me with dax to create a measure using above requirement.

 

thanks in advance..

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

I created a sample pbix file(see attachment) for you, please check whether that is what you want.

1. Create a country dimension table(Don't create any relationship with the fact table)

Countries = VALUES('Table'[Country])

yingyinr_0-1643886068763.png

2. Create a measure as below to get the sum of value

Measure =
VAR _selcountries =
    ALLSELECTED ( 'Countries'[Country] )
VAR _ou =
    CALCULATETABLE (
        VALUES ( 'Table'[OU] ),
        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Country] IN _selcountries )
    )
RETURN
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[OU] IN _ou )
    )

yingyinr_1-1643886193068.png

Best Regards

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @Anonymous ,

I created a sample pbix file(see attachment) for you, please check whether that is what you want.

1. Create a country dimension table(Don't create any relationship with the fact table)

Countries = VALUES('Table'[Country])

yingyinr_0-1643886068763.png

2. Create a measure as below to get the sum of value

Measure =
VAR _selcountries =
    ALLSELECTED ( 'Countries'[Country] )
VAR _ou =
    CALCULATETABLE (
        VALUES ( 'Table'[OU] ),
        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Country] IN _selcountries )
    )
RETURN
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[OU] IN _ou )
    )

yingyinr_1-1643886193068.png

Best Regards

Anonymous
Not applicable

thanks for your quick response, i was able to reslove it.

ValtteriN
Super User
Super User

Hi,

You can use logic like this:

ValtteriN_0-1643366688318.png


So here we will calculate sum of values based on material. i.e. if we have item1 or item4 selected the value will be 5

Dax:

Var example =
var _selection = MAX('Matrix example'[Material]) return
CALCULATE(SUM('Matrix example'[Value]),ALL('Matrix example'),'Matrix example'[Material]=_selection)


End result:
ValtteriN_1-1643366762582.png



You can apply same logi, but instead of items and material you have continent and country.

I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!








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

Proud to be a Super User!




amitchandak
Super User
Super User

@Anonymous , try a measure like

measure =
Var _tab = summmarize(filter(Table, Table[Country] in allselected(Table[Country])), Table[OU])
return
calculate(Sum(Table[Value]), filter(all(Table[OU]), Table[OU] in _tab))

 

 

That will still keep selected country/countries 

if you want display all countries , the have independent country, OU Table 
measure =
Var _tab = summmarize(filter(Country, Country[Country] in allselected(Country[Country])), Country[OU])
return
calculate(Sum(Table[Value]), filter(Table, Table[OU] in _tab))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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