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
Raph
Helper III
Helper III

Slice on an element present in different fields

Hello,

 

Let's say I have products with different possible colors.

I would like to have a pivot table with one color that can be present in different fileds. In the exemple below, I would like to have Green on the row of my pivot table which will sum the sales of Product2, Product4 and Product6.

 

Raph_0-1655975895409.png

 

How do you suggest to proceed?

 

Thank you

 

Raphaël

 

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @Raph 
Please do the following

Create a filter table containing all colors 

2.png

Colors = 
SELECTCOLUMNS (
    FILTER (
        DISTINCT (
            UNION (
                VALUES ( Products[Color1] ),
                VALUES ( Products[Color2] ),
                VALUES ( Products[Color3] )
            )
        ),
        [Color1] <> BLANK ( ) 
    ),
    "Color", [Color1]
)

Then your measure would be

1.png

Number of Products = 
VAR SelectedColor = SELECTEDVALUE ( Colors[Color] )
RETURN
    COUNTROWS ( 
        FILTER ( 
            Products,
            Products[Color1] = SelectedColor
                || Products[Color2] = SelectedColor
                || Products[Color3] = SelectedColor
        )
    )

View solution in original post

2 REPLIES 2
Raph
Helper III
Helper III

Thank you very much !

tamerj1
Super User
Super User

Hi @Raph 
Please do the following

Create a filter table containing all colors 

2.png

Colors = 
SELECTCOLUMNS (
    FILTER (
        DISTINCT (
            UNION (
                VALUES ( Products[Color1] ),
                VALUES ( Products[Color2] ),
                VALUES ( Products[Color3] )
            )
        ),
        [Color1] <> BLANK ( ) 
    ),
    "Color", [Color1]
)

Then your measure would be

1.png

Number of Products = 
VAR SelectedColor = SELECTEDVALUE ( Colors[Color] )
RETURN
    COUNTROWS ( 
        FILTER ( 
            Products,
            Products[Color1] = SelectedColor
                || Products[Color2] = SelectedColor
                || Products[Color3] = SelectedColor
        )
    )

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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