Forum Discussion
Anonymous
6 years agoNot applicable
Can I set a column name as variable in DAX?
Hi there 🙂 I want to be able to change the column name referenced in a DAX formula - for example here I want to be able to change the column name where it says "YTD", so that this is based on a ...
- 6 years ago
Anonymous Not exactly within the square brackets, but you could try a SWITCH function to get the result you're after:
Here's an example I made up:
Test Slicer Column =
SUMX(FILTER('Blank Values',VAR _Column =SWITCH(SELECTEDVALUE(Slicer[Column Select]), "Year", 'Blank Values'[Year], "Key", 'Blank Values'[Key])RETURNCONTAINSSTRING(_Column ,"2018")), 'Blank Values'[Value])
AllisonKennedy
Community Champion
6 years agoAnonymous Not exactly within the square brackets, but you could try a SWITCH function to get the result you're after:
Here's an example I made up:
Test Slicer Column =
SUMX(FILTER('Blank Values',
VAR _Column =
SWITCH(SELECTEDVALUE(Slicer[Column Select])
, "Year", 'Blank Values'[Year]
, "Key", 'Blank Values'[Key])
RETURN
CONTAINSSTRING(_Column ,"2018")), 'Blank Values'[Value])