Forum Discussion
conditional formatting
- 3 years ago
Hi HAMZA_07
On the columns Date, Net Positions, Long %, Short %, TOTAL and Index you apply the custom format has a value using the metric TOP Rows Format:
On the columns for the long / short where you want to have the divergent you apply the divergent but instead of select the value of the column you select the measure Percentile variation (short or long depending).
The blank values that are marked in my case has blue you need to set to yellow
To color the first three rows with fixed colors and use conditional formatting on the rest of the rows in a Power BI table, you can use the following steps:
- Create a new column in your table that assigns a fixed color to the first three rows and a default color to the rest. You can do this using a calculated column with a formula similar to the following:Copy codeFixed Color = IF ( RANKX ( ALL ( 'Table' ), [Column] ) <= 3, SWITCH ( RANKX ( ALL ( 'Table' ), [Column] ), 1, "#FF0000", 2, "#00FF00", 3, "#0000FF", "#FFFFFF" ), "#FFFFFF" )
This formula uses the RANKX function to assign a rank to each row based on the value of the "Column" field, and then uses the SWITCH function to assign a fixed color to the first three ranks and a default color to the rest. You can adjust the colors as needed by modifying the values in the SWITCH function.
Go to the "Format" tab for the table visual and click on the "Conditional formatting" button in the "Data colors" section.
In the "Conditional formatting" window, select the "Field" that you want to use for the conditional formatting, and then set the "Format by" option to "Color scales".
In the "Color scales" section, select the default color that you want to use for the rest of the rows.
In the "Data colors" section, set the "Data colors" option to "Fixed" and then select the "Fixed color" column that you created in step 1.
Click the "OK" button to apply the formatting to the table.