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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Clament
Regular Visitor

DAX measure

I need help i wrote DAX measure for clustered column chat to return green when the target is achieved and red when is not i have two columns Target and Measure my DAX formual is (color=if([target]>[Actual], "red", "green") )i get an error "The value for 'target' cannot be determined. Either the column doesn't exist, or there is no current row for this column" i dont know how to resolve this. 

 

1 ACCEPTED SOLUTION

Hi @Clament ,

As the one what I said in my previous post, we can't make conditional formatting for the column chart. We can refer the method in the following blog to get the same requirement.

How to do conditional formatting in Power BI Column Charts

I updated your sample pbix file(see the attachment), please check if that is what you want. 

1. Create two measures as below to get the sum of actual with different conditions

Above Actual = 
IF (
    SUM ( 'Sheet1'[target] ) <= SUM ( 'Sheet1'[actual] ),
    SUM ( 'Sheet1'[actual] )
)
Below Actual = 
IF (
    SUM ( 'Sheet1'[target] ) > SUM ( 'Sheet1'[actual] ),
    SUM ( 'Sheet1'[actual] )
)

2. Put the above measures onto the visual to replace the field [actual] with the aggregation "Sum" and set the different color for them

yingyinr_0-1676449478149.png

yingyinr_1-1676449497997.png

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

7 REPLIES 7
Clament
Regular Visitor

i wrote the measure but the bars are not Changing colors below is the screenshot.Screenshot (47).png

Hi @Clament ,

How did you apply and set the measure [color] on the visual? What's your final expected result? The conditional formatting is currently suitable for table or matrix visualization.

Apply conditional formatting in tables and matrixes

Could you please provide some raw data in your table (exclude sensitive data) with Text format and your expected result with backend logic and special examples? It would be helpful to find out the solution or an workaround. You can refer the following links to share the required info:

How to provide sample data in the Power BI Forum

How to Get Your Question Answered Quickly

And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

i used clustered column chart. i want the bars for actual to return only red and green based on the value of the target for example if the target is 50% and actual is 60% i want the bar for actual to be green. i wrote my measure then open the virtual and check the measure on the fields nevigation side.

Hi @Clament ,

Base on my research, there is no option or settings can make conditional formatting on the bar of column chart. Could you please share a simplified pbix file with fake data? You can refer the following link to upload the file to the community. Later I can check if there is any workaround can achieve the similar requirement. Thank you.

How to upload PBI in Community

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @Clament ,

As the one what I said in my previous post, we can't make conditional formatting for the column chart. We can refer the method in the following blog to get the same requirement.

How to do conditional formatting in Power BI Column Charts

I updated your sample pbix file(see the attachment), please check if that is what you want. 

1. Create two measures as below to get the sum of actual with different conditions

Above Actual = 
IF (
    SUM ( 'Sheet1'[target] ) <= SUM ( 'Sheet1'[actual] ),
    SUM ( 'Sheet1'[actual] )
)
Below Actual = 
IF (
    SUM ( 'Sheet1'[target] ) > SUM ( 'Sheet1'[actual] ),
    SUM ( 'Sheet1'[actual] )
)

2. Put the above measures onto the visual to replace the field [actual] with the aggregation "Sum" and set the different color for them

yingyinr_0-1676449478149.png

yingyinr_1-1676449497997.png

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-yiruan-msft
Community Support
Community Support

Hi @Clament ,

According to your description, it seems that you are creating a measure. Please update the formula of measure as below using the aggregation function, later check if it can return your expected result. 

color = IF ( SUM ( [target] ) > SUM ( [Actual] ), "red", "green" )

In addition, you can review the following blog for more details about DAX errors....

Wrong measure reference

If the above one can't help you, could you please provide more raw data in your table (exclude sensitive data) with Text format and your expected result with backend logic and special examples? It would be helpful to find out the solution. You can refer the following links to share the required info:

How to provide sample data in the Power BI Forum

How to Get Your Question Answered Quickly

And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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