Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

SWITCH Function not giving correct result

Hey 🙂 I have a problem with a task and maybe someone here can help me to solve it. I have listed projects and their revenue in the Excel table. Now I want to visualize the data and create a chart us...
  • Jihwan_Kim's avatar
    4 years ago

    Hi,

    If you are creating a calculated column (not measure) in the table, please try the below to create a new column.

     

    ProjectCategory =
    VAR Revenue = XXX[YYY]
    RETURN
        SWITCH ( TRUE (), Revenue >= 50, "C", Revenue <= 50, "S" )
    

     

  • tamerj1's avatar
    tamerj1
    4 years ago

    Anonymous 

    Thank you for the clarification. Unfortunately it doesn't work like this. You need to create a calculated column as suggested by Jihwan_Kim and then use it to slice you visual. Then you can create a measure such as COUNTROWS ( TableName ) or just drag the Project column in the Values of the visual ans summarize it by count or distinctcount as needed. 

  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi Anonymous ,

     

    Please try below steps:

    1.Add a new column to table

    Project Catagory =
    SWITCH (
        TRUE,
        'Table'[Planned Revenue] <= 50, "S",
        'Table'[Planned Revenue] > 50, "C"
    )

     

    2.Visualize the data with pie chart

     


    Best regards,
    Community Support Team_ Binbin Yu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.