Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Union Columns by Row Value

Hello everyone,   I am quite new in DAX. I had a problem to select column according to row value.   Here is an example data: Every student has scores in 5 different sport category. I wan...
  • Anonymous's avatar
    Anonymous
    6 years ago

    Anonymous I have an approach to solve your problem.

    Measure = 
    VAR _favorite = MAX('Table'[Favorite Sport])
    RETURN SWITCH(TRUE()
                    ,_favorite="gymnastics",SUM('Table'[gymnastics])
                    ,_favorite="Cycling",SUM('Table'[Cycling])
                    ,_favorite="Basketball",SUM('Table'[Basketball])
                    ,_favorite="Soccer",SUM('Table'[Soccer])
                    ,_favorite="Running",SUM('Table'[Running])
                    ,0
    )

    Please let me know if you have question. 

    If it solve your purpose mark it as solved.