Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
prabhatnath
Advocate III
Advocate III

Conditional Formatting on Card Visual that has Filters using Measure in the Field

Hello Friends,

I have a Card Visual that is using a Measure (named: WorkItemCount) in the Fields and multiple Filters are applied

Internally the  WorkItemCount Measure using the below formula/column of the table:

WorkItemCount = 
var _workitems = COUNT('Table1'[Work Item Id])
return
IF(ISBLANK(_workitem), 0, _workitem)

The above measure is being used in multiple Cards and working as expected.

Now I want to change the forecolor of the card value to Green if the displayed result (post filter) is ZERO or else RED Color for any positive numbers. For this, I have used Field Value conditional Formating and used the Color Measure. 

 

Here is the Color Measure and formula:

Colour = 
var _workitems = SELECTEDVALUE('Table1'[Work Item Id])
var _forecolor = SWITCH(
TRUE(),
_workitems = 0, "#33AE81",
_workitems > 0, "#DC5B57")
return
_forecolor

I am not able to use  WorkItemCount Measure inside the Color Measure so I have used the Base Column [Work Item Id] which is used inside the WorkItemCount Measure. But this seems to work only for 0 and 1 values, but not for values that are greater than 1. Not able to find the issue or something wrong I am doing here.

 

Thanks,

Prabhat

1 ACCEPTED SOLUTION
nvprasad
Solution Sage
Solution Sage

Hi

Can you try below DAX. It should work as you expected.

IF (WorkItemCount = 0, "#33AE81", "#DC5B57")

 

Appreciate a Kudos! ‌‌
If this helps and resolves the issue, please mark it as a Solution! ‌‌

Regards,
N V Durga Prasad

View solution in original post

2 REPLIES 2
prabhatnath
Advocate III
Advocate III

@nvprasad Thanks, It worked like a champ. It is simple and easy too.

nvprasad
Solution Sage
Solution Sage

Hi

Can you try below DAX. It should work as you expected.

IF (WorkItemCount = 0, "#33AE81", "#DC5B57")

 

Appreciate a Kudos! ‌‌
If this helps and resolves the issue, please mark it as a Solution! ‌‌

Regards,
N V Durga Prasad

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.