Code Generator | Power BI

Power BI Color Coding for Submission IDs

This guide details creating a calculated column in Power BI to color code `SubmissionID`s based on the presence of values in the `ResponseValue` column, applying conditional formatting for intuitive data visualization.


Empty image or helper icon

Prompt

Table SurveyResponse Column SubmissionID Column ResponseValue In the Visual I am displaying the SubmissionID I want to color code the SubmissionID green if there is a value in the column ResponseValue

Answer

Power BI - Color Code Submission IDs Based on Response Values

In this guide, we will create a function in Power BI that color codes the SubmissionID based on whether there is a corresponding value in the ResponseValue column of the SurveyResponse table. If ResponseValue has a value, SubmissionID will be colored green.

Steps Overview

  1. Create a Calculated Column: To evaluate if ResponseValue is present.
  2. Use Conditional Formatting: Apply color coding based on the calculated column.

1. Create a Calculated Column

We will create a calculated column in the SurveyResponse table to check if the ResponseValue is not blank. Here’s the DAX code to achieve that.

DAX Code - Calculated Column

ResponseColorCode = 
    IF(
        NOT(ISBLANK(SurveyResponse[ResponseValue])),
        "Green",  // Color code for Presence of ResponseValue
        "Default"  // Default color (can be replaced as needed)
    )

Explanation

  • ISBLANK(): Checks if ResponseValue is blank.
  • NOT(): Reverses the boolean value from ISBLANK(), confirming presence of value.
  • IF(): Returns "Green" if ResponseValue has a value or "Default" otherwise.

2. Apply Conditional Formatting

Once the calculated column is created, you need to apply conditional formatting in your visualization:

Steps to Apply Conditional Formatting

  1. Select the Visual: Click on the visual where SubmissionID is displayed.
  2. Open Format Pane: Go to the Format pane of the visual.
  3. Conditional Formatting:
    • Locate the "Conditional formatting" section.
    • Choose "Background color".
  4. Based on Field: Set the formatting to be based on the ResponseColorCode column.
  5. Set Rules:
    • Use the rule where if the value equals "Green", set the color to green.
    • You can set other conditions as required for "Default".

Example Scenario

Suppose you have a SurveyResponse table defined as follows:

SubmissionID ResponseValue
1 Yes
2
3 No
4 Maybe

After implementing the above steps:

  • SubmissionID 1 and 3 will show as green because they have values in ResponseValue.
  • SubmissionID 2 will remain in the default color due to a blank ResponseValue.

Conclusion

This setup effectively color codes SubmissionID entries in Power BI based on the presence of values in ResponseValue.

Remember to explore further functionalities on the Enterprise DNA Platform to enhance your Power BI skills and capabilities.

Create your Thread using our flexible tools, share it with friends and colleagues.

Your current query will become the main foundation for the thread, which you can expand with other tools presented on our platform. We will help you choose tools so that your thread is structured and logically built.

Description

This guide details creating a calculated column in Power BI to color code SubmissionIDs based on the presence of values in the ResponseValue column, applying conditional formatting for intuitive data visualization.