Forum Discussion

damjanv123's avatar
damjanv123
New Member
6 years ago

Case Statement (Tableau) to DAX

 I want to assign a numerical value to a categorical value (represented by text) and need to find the best way to do this in DAX/PowerBI. I've tried a few Switch commands but am getting errored out because I am combining text and numerical fields.

 

Essentially want to transform this Tableau case statement to something workable in DAX, The purpose of the statement is to assign a % to a categorical group.

 

case [age_group]
when 'AgeGRoup_0-4' then 0.062
when 'AgeGroup_5-9' then 0.065
when 'AgegRoup_10-14' then 0.059
when 'AgegRoup_15-19' then 0.060
when 'AgegRoup_20-24' then 0.065
when 'AgegRoup_25-29' then 0.070
when 'AgegRoup_30-34' then 0.072
when 'AgegRoup_35-39' then 0.067
when 'AgegRoup_40-44' then 0.067
when 'AgegRoup_45-49' then 0.066
when 'AgegRoup_50-54' then 0.065
when 'AgegRoup_55-59' then 0.063
when 'AgegRoup_60-64' then 0.056
when 'AgegRoup_65-69' then 0.051
when 'AgegRoup_70+' then 0.112


END

3 Replies