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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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