Forum Discussion

Clament's avatar
Clament
Regular Visitor
3 years ago
Solved

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. 

 

  • Anonymous's avatar
    Anonymous
    3 years ago

    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

    Best Regards

7 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    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

  • Clament's avatar
    Clament
    Regular Visitor

    i wrote the measure but the bars are not Changing colors below is the screenshot.

    • Anonymous's avatar
      Anonymous
      Not applicable

      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

      • Clament's avatar
        Clament
        Regular Visitor

        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.