Forum Discussion

Rewind's avatar
Rewind
Icon for Helper I rankHelper I
7 years ago
Solved

If filter is "Multiple Values"?

I'm very new to Power BI so apologies if this seems like an easy solution.

 

I'm not sure if the following is possible but ideally I'd like to create a new measure where.

 

If the filter for [Name] has Multiple selected calculate x

If the filter for [Name] has only one selected calculate y

 

 

  • Rewind

     

    Try HASONEVALUE or HASONEFILTER functions in DAX

     

    SOmething like

     

    =
    IF ( HASONEVALUE ( Table1[Name] ), [Measure1], [Measure2] )
    
  • Hi Rewind,

     

    What can we do with the no selected? It could be like this one.

     

    Measure 23 =
    VAR total =
        CALCULATE ( COUNT ( DimProduct[ColorName] ), ALL ( DimProduct[ColorName] ) )
    RETURN
        IF (
            HASONEVALUE ( DimProduct[ColorName] ),  // one selected.
            [Y],
            IF (
                COUNT ( DimProduct[ColorName] ) > 1
                    && COUNT ( DimProduct[ColorName] ) < total,  //multi-selected.
                [X],
                [Other Measure]  // no selected.
            )
        )
    

     

    Best Regards,
    Dale

3 Replies

  • Zubair_Muhammad's avatar
    Zubair_Muhammad
    Icon for Community Champion rankCommunity Champion

    Rewind

     

    Try HASONEVALUE or HASONEFILTER functions in DAX

     

    SOmething like

     

    =
    IF ( HASONEVALUE ( Table1[Name] ), [Measure1], [Measure2] )
    
  • v-jiascu-msft's avatar
    v-jiascu-msft
    Icon for Microsoft Employee rankMicrosoft Employee

    Hi Rewind,

     

    What can we do with the no selected? It could be like this one.

     

    Measure 23 =
    VAR total =
        CALCULATE ( COUNT ( DimProduct[ColorName] ), ALL ( DimProduct[ColorName] ) )
    RETURN
        IF (
            HASONEVALUE ( DimProduct[ColorName] ),  // one selected.
            [Y],
            IF (
                COUNT ( DimProduct[ColorName] ) > 1
                    && COUNT ( DimProduct[ColorName] ) < total,  //multi-selected.
                [X],
                [Other Measure]  // no selected.
            )
        )
    

     

    Best Regards,
    Dale