Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

VALUES is not retuning correct result inside switch function.

I created a DAX in which I am use values of a slicer and based on that calcuations are happened. but the Values is not returning correct result.   PY_test = IF(HASONEVALUE('Time Intelligence'[Pe...
  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi Anonymous .

    Use this DAX instead;

    PY_test =
    var a=SELECTEDVALUE(Time Intelligence'[Period]),
    SWITCH(
    TRUE(),
    a = "W",CALCULATE([Value],'Prior Year'[Name] = "PY",a = "W"),
    a = "4W",CALCULATE([Value],'Prior Year'[Name] = "PY",a = "4W"),
    a = "12W",CALCULATE([Value],'Prior Year'[Name] = "PY",a = "12W"),
    a = "52W",CALCULATE([Value],'Prior Year'[Name] = "PY",a = "52W")
    ))

    Let me know if that works.

    Thanks,
    Sanket


    If this post helps, then mark it as "Accept as Solution" and give it a thumbs up.