Forum Discussion

peterg0417's avatar
peterg0417
Helper III
2 years ago
Solved

Conditional Formatting on a Attribute/Value table

Hello all - I have a business request to conditionally format 2 date lines in a table and highlight the values red if we're within 90 days of the date. I tried with ChatGPT, but it couldn't get me th...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi peterg0417 

     

    Thanks for your explaination, please try this:

    First of all, I add a measure:

     

    Measure = 
    	VAR _DateofAttribute = SELECTEDVALUE('Table'[Attribute]) = "Effective Date" || SELECTEDVALUE('Table'[Attribute]) = "Expiration Date"
    	VAR _DateDiff = IF(
    		_DateofAttribute,
    		ABS(DATEDIFF(
    				DATEVALUE(SELECTEDVALUE('Table'[Formatted Value])),
    				TODAY(),
    				DAY
    			))
    	)
    	RETURN
    		IF(
    			_DateDiff <> BLANK() && _DateDiff < 90,
    			"Red"
    		)

     

    Then click the [Formatted Value] field and choose the Conditional formatting > Font color

    Choose Field value and select the measure in the what field should we base this on? multi-check box.

    The result is as follow:

     

    Best Regards

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