Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago

Rules based on Date Column in FACT Table

Hi Experts

 

Need a DAX measure as a calculated column to work out the following rule inorder to colour a bar chart visual, here is the rule

1. If the date is in the past then red and colour code 1,

2. if the date is next month from today date (ie. we are in Nov now and next month is Dec 21) then Amber and colour code 2

3, if the date is in the future +1 month from todays date i.e Start date is Jan 22 then Green and colour code 3...

7 Replies

  • Anonymous , You can directly return an color and use that in conditional formatting using filed value option

     

    a measure  =

    Switch(true() ,

    max('Date'[Date]) < Today() , "Red",

    max('Date'[Date]) < Today()+30 , "Amber",

    "Green"

    )

     

    How to do conditional formatting by measure and apply it on pie?: https://youtu.be/RqBb5eBf_I4

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Amit, should this by max('Date'[Date]) < Today()+30 , "Amber" or max('Date'[Date]) > Today()+30 , "Amber"

      • amitchandak's avatar
        amitchandak
        Super User

        Anonymous , You need amber till december eom then

         

        max('Date'[Date]) < eomonth(Today(),1)  , "Amber",

         

        Only 30 days

        max('Date'[Date]) < Today()+30 , "Amber",

        from today to next 30 days

  • v-janeyg-msft's avatar
    v-janeyg-msft
    Community Support

    Hi, Anonymous 

     

    If you want to create a calculated column.

    You can try:

    SWITCH (
        TRUE (),
        [Date] < TODAY (), "Red",
        [Date]
            >= EOMONTH ( TODAY (), 0 ) + 1
            && [Date] <= EOMONTH ( TODAY (), 1 ), "Amber",
        "Green"
    )

    The sample you provided doesn't seem to have any effect, we don’t know what kind of results you want.

     

    Did I answer your question ? Please mark my reply as solution. Thank you very much.
    If not, please upload some insensitive data samples and expected output.

     

    Best Regards,
    Community Support Team _ Janey