Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Highlighting new items

This might be a pretty simple thing to do but I am fairly new to Power BI and still trying to learn. I have a simple table of tasks and I want to highlight new items. For instance, anything that is posted within 7 days gets highlighted based on the Date reported which I do have within my Data.

 

IssueTypeDate ReportedDate ResolvedStatusImpactDetails
Issue1Issue18.10.2022 on-goingImpact1Impact1
Issue2Issue08.10.202219.10.2022on-goingImpact2Impact2

 

  • Hi Anonymous 

     

    I just used your code in  the example file I created for you and it highlights in red anything that is more than 7 days in the past 

     

    Check example PBIX file

     

    You said you wanted to highlight things posted in the past 7 days, not more than 7 days ago?

     

    To highlight things in the past 7 days you want to use greater than or equal to in the code, the code you posted is using less than or equal to 

     

    New = IF(SELECTEDVALUE('Issues'[Date Reported]) <= TODAY()-7"red")

     

    regards

     

    Phil

7 Replies

  • Hi Anonymous 

     

    I just used your code in  the example file I created for you and it highlights in red anything that is more than 7 days in the past 

     

    Check example PBIX file

     

    You said you wanted to highlight things posted in the past 7 days, not more than 7 days ago?

     

    To highlight things in the past 7 days you want to use greater than or equal to in the code, the code you posted is using less than or equal to 

     

    New = IF(SELECTEDVALUE('Issues'[Date Reported]) <= TODAY()-7"red")

     

    regards

     

    Phil

  • Hi Anonymous 

     

    Download example PBIX file with the code and data below

     

    You can create a measure like this

     

    New = IF(SELECTEDVALUE('DataTable'[Date Reported]) >= TODAY()-7, "#ADD8E6")

     

     

    which sets a color defined by the HEX code #ADD8E6 (pale blue) and this can be used in a Conditional Formatting rule to change the background color of the cells in the table.  Set the HEX code to anything you like

     

    More color codes here https://htmlcolorcodes.com/

     

    After creating the measure, add the CF rule

     

     

    Using these settings for the rule

     

    Resulting in this

     

    NOTE You have to create a separate CF rule for each column (Value), PBI won't let you set a rule for an entire row.

     

    Regards

     

    Phil

     

     

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      with your measure 

      New = IF(SELECTEDVALUE('Issues'[Date Reported]) <= TODAY()-7, "red") and steps you provided It doesn't highlight anything. It needs to highlight the past 7 day's period
      • PhilipTreacy's avatar
        PhilipTreacy
        Super User

        Hi Anonymous 

         

        So you've created the Conditional Formatting rule after creating the measure? 

         

        Without seeing your data and the rule you wrote I can't say for sure what is wrong.  Can you supply your file or at least the data (as text or table - not an image) you are running the CF rule against?

         

        regards

         

        Phil

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

    Please try below steps:

    1. create a measure with below dax formula

    Measure =
    VAR cur_date =
        TODAY () - 7
    VAR cur_reportdate =
        SELECTEDVALUE ( 'Table'[Date Reported] )
    RETURN
        IF ( cur_reportdate <= cur_date, "red" )
    

    2. set the conditinal format for field background

    For more details about , you can read related document: Apply conditional table formatting in Power BI - Power BI | Microsoft Learn

    Please refer the attached .pbix file.

     

    Best regards,
    Community Support Team_ Binbin Yu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • Hi Anonymous 

     

    Your measure for assigning the color is looking for dates that are greater than or equal to TODAY - 7 days.  At time of writing that means it will highlight things from 28 Oct onwards

     

    But in your data the latest date is Oct 24th so that's why nothing is being highlighted.

     

    regards

     

    Phil