Forum Discussion

DW868990's avatar
DW868990
Helper IV
3 years ago
Solved

Switch Help when multiple selections, to return single value

Hi,   I have the below switch statement -    ErrorSwitch = SWITCH(     TRUE(),     [PageFilters] = "Product1", 1,     [PageFilters] = "Product1" & "Product2", 2 )   The measure within the...
  • ValtteriN's avatar
    ValtteriN
    3 years ago

    Hi,

    You can expand on the logic e..g:


    Measure 21 =
    var _filter =
    VALUES('Table (9)'[Item])

     

    var _count = COUNTROWS(FILTER('Table (9)','Table (9)'[Item] in {"Peach","Pumpkin","Apple"}))
    return

     

    SWITCH(TRUE(),
    _count=1 && MAX('Table (9)'[Item]) = "Peach",1,
    _count=2,2,
    _count=3,3
    )


    The basic idea with switch + true is the following:

    SWITCH(TRUE(),
    Condition1, Result1,
    Condition2, Result2,
    Condition3, Result3,
    ...)

    So you can keep addiding conditions and scenarios to mathc your logic.