Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Comparing negative numbers in DAX?

Hi, this might be a silly question but I can't figure out how to achieve it.

 

I have a financial table that has a column called "% Decrease" which shows the % decrease of payments. An example value would be "-76%"

 

I want to add a calculated column that says if the percentage is between "-100%" and "-49%" then "Yes" else "No" - what would be the best way to achieve this?

  • Hi Anonymous ,

     

    Go to "Data view">"Modeling">"New Column",then add a dax expression as below:

     

    Column = IF('Table'[% Decrease]>-1 &&'Table'[% Decrease]<-0.49,"Yes","No")

     

     

    Then you will see:

     

     

    Best Regards,
    Kelly

5 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hey,

    is the value in the datasource -76% (and thus being a string)
    or is it -0.76 and did you use the modeling function in Power BI to make it a percentage?

    If the first, you should, and need to model it like -0.76 and use the modeling function to make it a percentage.

    If the last, you can create a dax formula looking something like this:

    COLUMN = IF(Columnwith-76% > -1 && < -0,49;"yes";"no")
  • If the column is already in table then create a column. 

     

    new column = if(table[% Decrease]>=-100  && table[% Decrease]<=-49,"Yes","No")

     

    If the % decrease is a measure create a measure

    measure = if([% Decrease]>=-100  && [% Decrease]<=-49,"Yes","No")

    Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
    Thanks. My Recent Blog -
    Winner-Topper-on-Map-How-to-Color-States-on-a-Map-with-Winners , HR-Analytics-Active-Employee-Hire-and-Termination-trend
    Power-BI-Working-with-Non-Standard-Time-Periods And Comparing-Data-Across-Date-Ranges

    Connect on Linkedin

  • FrankAT's avatar
    FrankAT
    Icon for Community Champion rankCommunity Champion

    Hi,

    use the following formula:

    If ( Table[% Decrease] >= -1 && Table[% Decrease]  <= -0.49 ; "Yes" ; "No")

     

    Regards FrankAT

  • VasTg's avatar
    VasTg
    Icon for Memorable Member rankMemorable Member

    Anonymous 

     

    Add a custom column as below

     

    =if [Column1] <= -0.49 and [Column1] >= -1 then "Yes" else "No"

     

    Replace Column1 with your actual column name

     

    If this helps, mark it as a solution

    Kudos are nice too

     

     

  • v-kelly-msft's avatar
    v-kelly-msft
    Icon for Community Support rankCommunity Support

    Hi Anonymous ,

     

    Go to "Data view">"Modeling">"New Column",then add a dax expression as below:

     

    Column = IF('Table'[% Decrease]>-1 &&'Table'[% Decrease]<-0.49,"Yes","No")

     

     

    Then you will see:

     

     

    Best Regards,
    Kelly