Forum Discussion
formatting time differences
- 9 months ago
Hi hastingse14
Download an example PBIX file here
I’d rewrite the measure so that it works out if a Time Diff is >7h or >10h and then decides what colour to use for the cell background, rather than return decimal values like 1 which you then have to write more code to decide colours
GT 7h = VAR _time_diff = SELECTEDVALUE('Time_Log'[Time Diff]) VAR _7h = 420 / 1440 VAR _10h = 600 / 1440 RETURN SWITCH( TRUE(), _time_diff > _10h, "red", _time_diff > _7h, "orange", "green" )The SWITCH function requires a default value which I have set to "green" here but if you don’t want a default (all cells will get this unless they are red or orange) then make it "" instead.
Click on the down arrow beside the Time Diff column in the visual and then select Conditional Formatting-> Background Color
Choose these settings and click OK
Your table should like something like this
Regards
Phil
Hello hastingse14,
Thank you for posting your query in the Microsoft Fabric Community Forum, and thanks to PhilipTreacy for sharing valuable insights.
Could you please confirm if your query has been resolved by the provided solutions? This would be helpful for other members who may encounter similar issues.
Thank you for being part of the Microsoft Fabric Community.