Forum Discussion

iLoatheMSDeep's avatar
iLoatheMSDeep
Regular Visitor
10 months ago
Solved

IF Statement with Slicer and Calculated Column

Apologies, I'm on the newer side of Power BI so still becoming acclimated with its quirks.  I am having difficulty understanding how to use the SELECTEDVALUE function properly. I have a slicer tha...
  • GeraldGEmerick's avatar
    10 months ago

    iLoatheMSDeep Calculated columns are not dynamic, they are only calculated when you load data. Therefore, you cannot use a calculated column in conjunction with a slicer. Instead, you will need to use a measure. I don't see anything in your calculated column that would prevent it from being a measure as currently written.

  • Anonymous's avatar
    Anonymous
    10 months ago

    Hi iLoatheMSDeep,

    Yes, you got the idea mostly right. The SELECTEDVALUE function gives one value only when a single month is selected in the slicer. If multiple months are selected or “Select All” is used, it will return blank  that’s why you are getting empty results.

    Also, measures in Power BI work based on the visual’s filter context, not for each row like a calculated column. So the IF condition will check for the selected month in the visual, not row by row.

    Try keeping your slicer in single-select mode, and it should start showing the correct text values.

    Hope this helps if you have any queries we are  happy to assist you further.
    Regards,
    Community Support Team.