Using Switch formula in the table as a new column

  • Using Switch formula in the table as a new column

    Posted by DSC Communities on January 5, 2023 at 4:18 pm
    • Waseem Dar

      Member

      January 5, 2023 at 4:18 PM

      Hello BI community – I added a column by right clicking on the table in Report view. The formula is

      ProjMarginLegend = SWITCH(TRUE(),[ProjMargin] < 0, “<0”, [ProjMargin] > 0.15, “>15%”, “0 to <15%”). When I change it to

      ProjMarginLegend = SWITCH(TRUE(),[ProjMargin] < 0, “<0”, [ProjMargin] >0 and < 0.10, “0 to <10%”, [ProjMargin] >=0.10 and < 0.15, “10% to <15%”, [ProjMargin] > 0.15, “>15%”,””), the formula does not work. Help is appreciated. ThanksĀ 

      ——————————
      Waseem Dar
      Business Analyst
      ——————————

    • jack vvnck

      Member

      January 6, 2023 at 4:08 AM

      try this format

      NEWCLM = SWITCH(
      Ā  Ā  TRUE(),
      Ā  Ā  0<[Sales Amount] && [Sales Amount]<=1000,“LOW”,
      Ā  Ā  1000<[Sales Amount] && [Sales Amount]<=5000,“MID”,
      Ā  Ā  5000<[Sales Amount] && [Sales Amount]<=10000,“HIG”,
      Ā  Ā  “OTH”
      )

      ——————————
      jack vvnck

      ——————————
      ——————————————-

    • Adam Artur Boltryk

      Member

      January 6, 2023 at 11:57 AM

      Hi Waseem,

      You should keep logic of < or > and DO NOT mix it. so:

      ProjMarginLegend =
      SWITCH(TRUE(),
      [ProjMargin] < 0, “<0”,
      [ProjMargin] < 0.10, “0 to <10%”,
      [ProjMargin] < 0.15, “10% to <15%”,
      “>15%”
      ),

      or

      ProjMarginLegend =
      SWITCH(TRUE(),
      [ProjMargin] > 0.15, “>15%”,
      [ProjMargin] > 0.10, “10% to <15%”,
      [ProjMargin] >= 0, “0 to <10%”,
      “<0”),

      Regards

      ——————————
      Adam Artur Boltryk
      Business Analyst
      ——————————
      ——————————————-

    DSC Communities replied 2 years, 9 months ago 1 Member · 0 Replies
  • 0 Replies

Sorry, there were no replies found.

The discussion ‘Using Switch formula in the table as a new column’ is closed to new replies.

Start of Discussion
0 of 0 replies June 2018
Now

Welcome to our new site!

Here you will find a wealth of information created for peopleĀ  that are on a mission to redefine business models with cloud techinologies, AI, automation, low code / no code applications, data, security & more to compete in the Acceleration Economy!