Forum Discussion
IF Statement with Slicer and Calculated Column
- 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.
- Anonymous10 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.
Ah thank you so much for the clarification; I'll keep that in mind going forward. I did try this as a measure, however, I am still getting blank values where I should be getting a text value. So that's why I assumed I didn't understand the 'SELECTEDVALUE' function properly. I believe I read that if there are multiple values in the table with that same data, that it will render blank. How I interpreted it though was that the user selects an option from the slicer, that one option is the Selected Value and the IF statement would be applied to all data in the table that matched the Selected Value. Apparently, that's not how it is supposed to work?
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.
- Anonymous10 months agoNot applicable
Hi iLoatheMSDeep,
I hope the information provided above assists you in resolving the issue. If you have any additional questions or concerns, please do not hesitate to contact us. We are here to support you and will be happy to help with any further assistance you may need.
Regards,
Community Support Team.- Anonymous9 months agoNot applicable
Hi iLoatheMSDeep,
I hope the above details help you fix the issue. If you still have any questions or need more help, feel free to reach out. We are always here to support you.
Regards,
Community Support Team.