Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredJoin us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.
Hello, I want help to color the first three rows with fixed colors, and the rest I want to use conditional formatting on them ....
as columns and not as rows
Solved! Go to Solution.
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
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsHi @HAMZA_07 ,
For this you need to do some advance editing of the condittional formating this also depends on how you want to format the rows below.
For the first 3 lines create a metric similar to this:
TOP ROWS FORMATTING = IF(SELECTEDVALUE('Table (2)'[Index]) <=3 , "#118DFF")
This need to be used on all your columns has condittional formatting.
For the Long and Short depends on how you want to do the conditional formatting if it's by the diverging colours you need to add the following two metrics for each column:
percentile long =
IF (
SELECTEDVALUE ( 'Table (2)'[Index] ) > 3,
CALCULATE (
PERCENTILE.EXC ( 'Table (2)'[Long], 0.5 ),
FILTER ( ALL ( 'Table (2)' ), 'Table (2)'[Index] > 3 )
)
)
Percentile_Long_Variation =
IF (
SELECTEDVALUE ( 'Table (2)'[Index] ) > 3,
SUM ( 'Table (2)'[Long] ) - [percentile long]
)
Now use this has the condittional formatting of the long column:
Be aware that you need to select the specific colour for empty values
If the Long/Short has specific rules the you need to change the percentile to the specific rules using a swich statment:
I have created the following rule for short:
Format Short =
SWITCH( TRUE(),
SELECTEDVALUE ( 'Table (2)'[Index] ) <= 3, "#118DFF",
SUM('Table (2)'[Short]) <= 11000, "Green",
SUM('Table (2)'[Short]) <= 14000, "Red",
SUM('Table (2)'[Short]) <= 99000, "BLue"
)
On the example above I only formated the Date , long short and net positions but you can do it for all the columns.
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsThank you for your reply, but I did not understand how to apply the new metric... I want the first three rows to be like what you applied in a picture, but in yellow color... and the columns like the picture below
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
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsBrilliant trick. Using a percentage column you made it read it's empty . thank you 😊
Did my solution worked?
You marked your answer has the solution. Is that correct?
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsSorry I fixed it. Thank you
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:
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.