Forum Discussion

tloup's avatar
tloup
Frequent Visitor
2 years ago
Solved

Error with conditional formatting and calculation items combining time intelligence and formatting

Hello 

 

I have a table that I want to be dynamic with time intelligence. I have therefore made a calculation group called time intelligence which allows users to switch between timeframes for all the metrics. I then wanted the format of these metrics to change depending on the timeframe because the numbers get a lot bigger / smaller depending on the timeframe selected. The final piece of formatting I want to show is a certain colour depending on the value of the metrics (i.e. if it is below target then 'red'). 

 

The problem I am facing is when I combine all these things together Power BI gives me an error saying I can't work with my number formatting and colour formatting at the same time. The error message says: 'Cannot convert value 'Red' of type Text to type Numeric'

The DAX code for my number formatting is the following:

IF ( OR ( CONTAINSSTRING ( SELECTEDMEASURENAME (), "*%*" ), CONTAINSSTRING ( SELECTEDMEASURENAME (), "CR*" ) ), FORMAT ( SELECTEDMEASURE (), "0%" ), FORMAT ( SELECTEDMEASURE () / 1000, "£#,0K" ) )


The DAX code for my conditional formatting is the following (I would like to change this to be dynamic using something like SELECTEDMEASURE () instead of selecting the individual measure but this doesn't seem to work) :

IF([Demand Sales vs BGT] < 0, "Red", BLANK())


Any help would be v gratefully received! 

  • tloup Can't seem to replicate this. Is the dynamic format for the measure [Demand Sales vs BGT]? Only thing I don't have is the calculation group involved. Any chance you can share a PBIX?

3 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    tloup Can't seem to replicate this. Is the dynamic format for the measure [Demand Sales vs BGT]? Only thing I don't have is the calculation group involved. Any chance you can share a PBIX?

  • seemakunnath's avatar
    seemakunnath
    Regular Visitor

    Did the above get resolved? I am trying to do something similar to format certain timeintelligence values of all SELECTEDMEASURE to have colours based on their values. 

     

     

    Is there a solution to this please?

    • PierreL69's avatar
      PierreL69
      Helper IV

      Hi I am encountering the same issue, did you resolve your issue ? thanks