Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Color Background for Line/Bar chart

Hi guys,   I'm trying to achieve something for a while now and that is creating a traffic light background for a client.   The bottom and middle part (red and yellow color) were easy to implement...
  • Anonymous's avatar
    Anonymous
    3 years ago

    The solution by the one and only Alberto Ferarri! 🙂 

    You're welcome, guys.   

    CALCULATIONITEM "12 months max" =
            VAR NumOfMonths = 12
            VAR ReferenceDate = MAX ( 'Date'[Date] )
            VAR PreviousDate =
                DATESINPERIOD ( 'Date'[Date], ReferenceDate, -NumOfMonths, MONTH )
            VAR ShowValue =
                NOT ISEMPTY ( INTERSECT ( PreviousDate, VALUES ( 'Previous Date'[Date] ) ) )
            VAR Result =
                CALCULATE (
                    MAXX ( VALUES ( 'Date'[Year Month] ), SELECTEDMEASURE ( ) ),
                    PreviousDate,
                    ALL ( 'Date' )
                )
            RETURN
                IF ( ShowValue, Result )