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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
amirabedhiafi
Impactful Individual
Impactful Individual

Change a column of a table based on a filter

I have a filter containing City/Country :

amirabedhiafi_0-1634392831331.png

I created a table Filters with a column Filtering containing City and Country like above.

When selecting City I want to display the target by city: 

amirabedhiafi_1-1634392950466.png

When selecting Country I want to display the target by country: 

amirabedhiafi_2-1634393001899.png

 

Knowing that I have other filters in the same page like semester ...

 

 

Amira Bedhiafi
Full Stack Business Intelligence Consultant @Capgemini
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @amirabedhiafi ,

Here are the steps you can follow:

1. Use Enter data to create a table.

vyangliumsft_0-1634711512283.png

2. Create measure.

City =
IF(
    CONTAINS(
        'Table',
        'Table'[Slicer Selection],"City"),
        SUMX(FILTER('Filters','Filters'[City]=MAX('Filters'[City])),'Filters'[Target]),BLANK())
Country =
IF(
    CONTAINS(
        'Table',
        'Table'[Slicer Selection],"Country"),       SUMX(FILTER('Filters','Filters'[City]=MAX('Filters'[City])&&'Filters'[Country]=MAX('Filters'[Country])),'Filters'[Target]),BLANK())

3. Use Table's [Slicer Selection] as the slicer

4. Result:

When choosing City as:

vyangliumsft_1-1634711512285.png

When choosing Country as:

vyangliumsft_2-1634711512286.png

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi  @amirabedhiafi ,

Here are the steps you can follow:

1. Use Enter data to create a table.

vyangliumsft_0-1634711512283.png

2. Create measure.

City =
IF(
    CONTAINS(
        'Table',
        'Table'[Slicer Selection],"City"),
        SUMX(FILTER('Filters','Filters'[City]=MAX('Filters'[City])),'Filters'[Target]),BLANK())
Country =
IF(
    CONTAINS(
        'Table',
        'Table'[Slicer Selection],"Country"),       SUMX(FILTER('Filters','Filters'[City]=MAX('Filters'[City])&&'Filters'[Country]=MAX('Filters'[Country])),'Filters'[Target]),BLANK())

3. Use Table's [Slicer Selection] as the slicer

4. Result:

When choosing City as:

vyangliumsft_1-1634711512285.png

When choosing Country as:

vyangliumsft_2-1634711512286.png

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

aj1973
Community Champion
Community Champion

Hi @amirabedhiafi 

Do you know how to use bookmarks? I would recommend it.

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

Yes just tried to use a trick with the filters instead of the bookmarks.

Amira Bedhiafi
Full Stack Business Intelligence Consultant @Capgemini

Well try with Bookmarks now,

Put 2 visuals on top of each others, select the filter, and depending on filter selection hide or keep the visual you need to see using bookmarks.

here is a video that could help you

https://www.youtube.com/watch?v=_Afcj8mT5_Q

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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