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
Anonymous
Not applicable

How to create slicer for multiple fact tables showing only active values in selected period

Hi community,

 

I need your help with creating slicer containing active values only.

 

I have three fact tables (plan1, plan2 and production) each connected to two dim tables (calendar and items).

 

Plan1

ItemNrDateQuantity
A10.7.202210
B10.8.20225
C12.8.20223
B5.9.20226

 

Plan2

ItemNrDateQuantity
A1.7.20225
A5.7.20225
B31.7.20225
C5.8.20223
B5.9.20226

 

Production

ItemNrDateQuantity
A30.6.20223
A2.7.20224
B1.8.20221
C1.8.20222
B7.9.20225

 

Items

ItemNrUoM
AKG
BPC
CM

 

I also have two slicers, date period from calendar and unit of measure (UoM) from items. What I want here is to filter slicer UoM to show only units active in selected period. Active means all UoM according to items tracked in at least one of the three fact tables in selected period.

 

In the example above for selected period

1.8.2022-31.8.2022 the slicer should offer PC and M,

1.6.2022-30.6.2022 the slicer should offer KG only.

 

I would appreciate any help. Thank you.

1 ACCEPTED SOLUTION

Try the below

Show slicer value = 
VAR SelectedItems =
    DISTINCT (
        UNION (
            VALUES ( Plan1[ItemNr] ),
            VALUES ( Plan2[ItemNr] ),
            VALUES ( Production[ItemNr] )
        )
    )
VAR CurrentItems =
    VALUES ( Items[ItemNr] )
RETURN
    IF ( NOT( ISEMPTY( INTERSECT( CurrentItems, SelectedItems))), 1 )

View solution in original post

4 REPLIES 4
johnt75
Super User
Super User

You could create a measure like

Show slicer value =
VAR SelectedItems =
    DISTINCT (
        UNION (
            VALUES ( Plan1[Item] ),
            VALUES ( Plan2[Item] ),
            VALUES ( Production[Item] )
        )
    )
VAR CurrentItem =
    SELECTEDVALUE ( Items[Item] )
RETURN
    IF ( CurrentItem IN SelectedItems, 1 )

and add that as a filter to the slicer visual, to only show when the value is 1

Anonymous
Not applicable

Unfortunately when I tried to use this solution in my original BI it didn't work. So I tried to find the reason for that. There is a scenario which causes the measure giving wrong result. If you add 1 row to Items table the measure won't work as expected anymore. @johnt75 , please take a look at that as I don't have enough knowledge to fix this.

Items

ItemNrUom
AKG
BPC
CM
DKG

Try the below

Show slicer value = 
VAR SelectedItems =
    DISTINCT (
        UNION (
            VALUES ( Plan1[ItemNr] ),
            VALUES ( Plan2[ItemNr] ),
            VALUES ( Production[ItemNr] )
        )
    )
VAR CurrentItems =
    VALUES ( Items[ItemNr] )
RETURN
    IF ( NOT( ISEMPTY( INTERSECT( CurrentItems, SelectedItems))), 1 )
Anonymous
Not applicable

@johnt75 , thank you very much. This is now the solution that works.

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.