Power BI Exchange

Please login or click SIGN UP FOR FREE to create your PowerBIUG account to join this user group.
 View Only
  • 1.  Using Switch formula in the table as a new column

    Silver Contributor
    Posted 28 days ago
    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
    ------------------------------


  • 2.  RE: Using Switch formula in the table as a new column

    Posted 28 days ago
    Edited by jack vvnck 28 days ago
    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

    ------------------------------



  • 3.  RE: Using Switch formula in the table as a new column

    Posted 27 days ago

    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
    ------------------------------