Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Conditional formatting Card - Callout value - negative numbers are ignored

Hi

 

I'm having problems with formatting a datacard value conditionally. I want to have the font in red, if the number is negative and green if it's positive. Hoped it would be a simpler matter 🙂

 

Anyway, the underlying data roughly looks as follows:

 

Invoice NumberGroupChange to last Invoice
123410.005
123420.005
123430.005
98761-0.02
98761-0.02
98762-0.02

 

As you see, I have a multi-indexed table (if that's important). But the group in this specific case is of no matter, since the change refers to the invoice anyway. This is the data I get from the database and I can not normalize it further for other purposes.

 

Anyhow, I drill-through the page using an Invoice number and want one change value in the datacard. This is naturally achieved with any aggregation function since it yields the same result anyway. I'm using max in my exampe (but my problem occurs with min/max/sum/avg etc. too)

 

The "change" column in the query editor is formatted to decimal and in the data tab of the editor I formatted it further to percentage (already formatting it into percentage in the query editor doesn't change the error unfortunately)

 

I tried every possible permutation in the image above. I also tried:

  • Green
    • If value >= MIN and < 1000
    • if value >=0 and < 1000
  • Red
    • if value >= Min and <= 0
    • if value >= -1000 and <= 0

And various other possibilities, all to no avail.

As you see in the image above, I tried working with decimal points, since I thought maybe the numbers are rounded somwhere in the background. Since the original underlying data is 0.05 for 5% for example, but that didn't work either.

What makes me doubt it could be a problem with the number formatting or anything is, that the conditional formatting works when it's a table:

 

 

Any ideas? I'm really confused here.

 

Thank you very much

  • Hi Anonymous 

    Thanks for reaching out to us.

    you can create a measure used for conditional formatting,  refer to 

    Solved: Conditional Formatting based on calculated measure - Microsoft Power BI Community

    Measure = 
    var V=CALCULATE(SUM('Table'[Value]))
    return IF(V>R[R Value],"#FD625E",
                IF(V>[A Value]&&V<R[R Value],"#F2C80F",
                    IF(V>G[G Value]&&V<R[R Value],"#01B8AA")))

    if you need more help, please share a sample file.

     

     

    Best Regards,

    Community Support Team _Tang

    If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

1 Reply

  • v-xiaotang's avatar
    v-xiaotang
    Community Support

    Hi Anonymous 

    Thanks for reaching out to us.

    you can create a measure used for conditional formatting,  refer to 

    Solved: Conditional Formatting based on calculated measure - Microsoft Power BI Community

    Measure = 
    var V=CALCULATE(SUM('Table'[Value]))
    return IF(V>R[R Value],"#FD625E",
                IF(V>[A Value]&&V<R[R Value],"#F2C80F",
                    IF(V>G[G Value]&&V<R[R Value],"#01B8AA")))

    if you need more help, please share a sample file.

     

     

    Best Regards,

    Community Support Team _Tang

    If this post helps, please consider Accept it as the solution to help the other members find it more quickly.