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