Forum Discussion

khisla's avatar
khisla
Icon for Helper II rankHelper II
1 year ago
Solved

DAX Command - IF variables, SWITCH and COALESCE

I need a DAX commend to identify the store to which an employee is based to sales commission calculation purposes Please find table of specific scenarios and expected results for each one. So I hav...
  • Cookistador's avatar
    Cookistador
    1 year ago

    Hello khisla 
    You added one ) in your second condition in the CASE
    Normally, the following measure should work

    Next=
    
     VAR EntranceStore = SELECTEDVALUE('HILAN'[Entrance Store])
     VAR ExitStore = SELECTEDVALUE('HILAN'[Exit Store])
     VAR DefaultStore = SELECTEDVALUE('HILAN'[Employee Default Store])
    
    RETURN
       SWITCH(
       TRUE(),
       NOT(ISBLANK(EntranceStore)) && EntranceStore <> DefaultStore, EntranceStore,
       NOT(ISBLANK(ExitStore)) && ExitStore <> DefaultStore, ExitStore,
       NOT(ISBLANK(EntranceStore)) || EntranceStore = DefaultStore || ISBLANK(ExitStore) || ExitStore = DefaultStore, DefaultStore,
         DefaultStore
        )