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 a dynamic slicer

the slicer is the distinct value of column type and is setted as singal select,
"Default" is the value that every id has, but other type may not, for example when id is B there is no value other than "Default".

null_0-1664248622940.png

 


here is the situation to be solved: when slicer is "Default", all values of column id return relevant rows,
and when slicer is not "Default", the id did not has other value return the "default" row and the id did not has default "default" return selected relevant row to be calculated
for example, when slicer is "Senior", id A returns type=Senior row and id B returns type=Default row
do you have any solutions to realize such a slicer?
Thank you.

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

One of ways to achieve this is to have disconnected slicer like below, and create measures like below.

 

Jihwan_Kim_1-1664253518173.png

 

 

Jihwan_Kim_0-1664253469737.png

 

Amount measure: =
VAR _slicerselect =
    SELECTEDVALUE ( Slicer[Type], "Default" )
VAR _result =
    CALCULATE ( SUM ( Data[Amount] ), KEEPFILTERS ( Data[Type] = _slicerselect ) )
RETURN
    IF (
        HASONEVALUE ( Data[ID] ),
        IF (
            ISBLANK ( CALCULATE ( SUM ( Data[Amount] ), Data[Type] = _slicerselect ) ),
            CALCULATE ( SUM ( Data[Amount] ), KEEPFILTERS ( Data[Type] = "Default" ) ),
            _result
        )
    )

 

Percentage measure: = 
VAR _slicerselect =
    SELECTEDVALUE ( Slicer[Type], "Default" )
VAR _result =
    CALCULATE ( SUM ( Data[Ratio] ), KEEPFILTERS ( Data[Type] = _slicerselect ) )
RETURN
    IF (
        HASONEVALUE ( Data[ID] ),
        IF (
            ISBLANK ( CALCULATE ( SUM ( Data[Ratio] ), Data[Type] = _slicerselect ) ),
            CALCULATE ( SUM ( Data[Ratio] ), KEEPFILTERS ( Data[Type] = "Default" ) ),
            _result
        )
    )

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


View solution in original post

2 REPLIES 2
Anonymous
Not applicable

very good solution, I wonder if these is a way to add such a measure as slicer to achieve that result

Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

One of ways to achieve this is to have disconnected slicer like below, and create measures like below.

 

Jihwan_Kim_1-1664253518173.png

 

 

Jihwan_Kim_0-1664253469737.png

 

Amount measure: =
VAR _slicerselect =
    SELECTEDVALUE ( Slicer[Type], "Default" )
VAR _result =
    CALCULATE ( SUM ( Data[Amount] ), KEEPFILTERS ( Data[Type] = _slicerselect ) )
RETURN
    IF (
        HASONEVALUE ( Data[ID] ),
        IF (
            ISBLANK ( CALCULATE ( SUM ( Data[Amount] ), Data[Type] = _slicerselect ) ),
            CALCULATE ( SUM ( Data[Amount] ), KEEPFILTERS ( Data[Type] = "Default" ) ),
            _result
        )
    )

 

Percentage measure: = 
VAR _slicerselect =
    SELECTEDVALUE ( Slicer[Type], "Default" )
VAR _result =
    CALCULATE ( SUM ( Data[Ratio] ), KEEPFILTERS ( Data[Type] = _slicerselect ) )
RETURN
    IF (
        HASONEVALUE ( Data[ID] ),
        IF (
            ISBLANK ( CALCULATE ( SUM ( Data[Ratio] ), Data[Type] = _slicerselect ) ),
            CALCULATE ( SUM ( Data[Ratio] ), KEEPFILTERS ( Data[Type] = "Default" ) ),
            _result
        )
    )

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


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.