Conditional formatting
Conditional formatting (fx) lets a setting take its value from your data instead of a fixed value. Use it to color circles by a measure, set a different image for each row, or switch a layer on and off with a slicer.
Before you start
- Conditional formatting is set in the Format pane. Look for the fx button next to a setting.
- The layer must be on, and the visual must have data, before its settings appear.
The Layer Manager and the Basemaps dialog write fixed values only. Power BI's conditional formatting windows cannot be opened from them, so every editor in the Layer Manager ends with a pointer to the Format pane group that holds the layer's fx settings.
Color circles by a measure
- In the Format pane, open Data Layers > Circles - Formatting.
- Select the fx button next to Fill Color.
- In Format style, choose Gradient, Rules or Field value.
- Choose the field or measure the color is based on, set the colors or rules, and select OK.
Each circle now takes the color worked out for its own row. To go back to one color, select the fx button again and remove the formatting, or use the eraser next to the setting.
How it works
Power BI works out a conditional formatting value for each value of the * ID (required) field, which is one value per row the visual receives. Icon Map Slicer reads that value when it draws the row.
The three format styles do different jobs:
| Format style | Use it for | Example |
|---|---|---|
| Gradient | A color that runs from low to high | Fill color from light to dark by sales |
| Rules | A fixed set of outcomes | Red when a status measure is 1, green when it is 2 |
| Field value | A value your data already holds, or a measure builds | A column of hex colors, an image URL, a line width, a Yes or No |
Field value is the one that makes non-color settings work. A measure can return a number for a width, text for a link, or "Yes" and "No" for a switch such as Visible.
Settings read from every row and settings read once
Most data layer settings are read for every row, so each item can differ. Some settings apply to a whole layer, such as a link, a resolution or a visibility switch. For those, Icon Map Slicer uses the value from the first row. Give them a measure that returns the same value on every row, for example a measure that reads a slicer selection.
| Read for every row | Read once for the layer |
|---|---|
| Colors, transparency, widths and sizes of circles, images, lines, columns and shapes | Links and URLs of file and tile layers |
| Selectable, Include Tooltip, Include in Auto Zoom | Visible switches of layers |
| Image URLs, rotations and icon names | Cell Resolution and its Min Value, Mid Value and Max Value |
| Label text and label colors | Catalog layer Layer Visible and Selected Variant |
Conditional formatting and selection
When a reader selects items, the map does not recolor them with your rules. Selected items keep their own colors and the rest fade, as set by Selection > Formatting. The other visuals on the page are filtered, and their own conditional formatting is worked out again for the filtered data.
When another visual filters Icon Map Slicer, the map receives only the remaining rows, and each setting with fx is worked out again for them. A gradient therefore spreads over the rows that are left.
Large datasets
Conditional formatting applies to every row the visual loads, including rows beyond the first 30,000 when you raise Maximum data rows. See Data rows and limits.
Patterns
Color from a column of color values
Hold a hex color such as #0c62a6 in a column, or build one in a measure. Select fx on the color setting, choose Field value, and pick the column or measure.
Per-row values without a field well
Some values have no field well and are set per row with Field value. Lines are the main example: Width, Color, Weight for Flow, Route Name and Dash Array all take a value per row this way. See Lines.
Show or hide per row
Selectable, Include Tooltip and Include in Auto Zoom are Yes or No settings that accept fx. Return "Yes" or "No" from a measure with Field value, or use Rules, to exclude some rows from selection, tooltips or the auto zoom. Rows that are not selectable cannot be used to filter the report. Display Label in Labels > Content works the same way for data labels.
Switch a layer or link with a slicer
Use a measure that reads the slicer, for example with SELECTEDVALUE, and bind it with Field value to a layer's Visible setting or to its link. The same measure value must come back on every row.
Filter a reference layer from your data
On a file reference layer, bind Filter Value with Field value. Icon Map Slicer reads the value from every row and shows the features that match any of them. See Files and feeds.
Pick the Map Location fields
Map Location filters the report by the area the map shows. Its two fields are picked with fx, not with field wells: on Selection > Map Location, select fx next to Longitude Field to Slice, choose Field value, and pick the longitude column. Do the same for Latitude Field to Slice. See Filter by the map view.
Legend entries from a field
In Legend > Legend labels, the description setting of each layer accepts fx > Field value to label legend entries from a data field. In Legend > Conditional formatting legends, the gradient field of a layer is also picked with fx > Field value. See Legend.
Settings that accept conditional formatting
Names are as they appear in the Format pane. A setting is listed only where the fx button is offered.
Data layers
| Layer | Group | Settings with fx |
|---|---|---|
| Circles | Circles - Configuration | Include in Auto Zoom, Include Tooltip, Selectable |
| Circles | Circles - Formatting | Fill Color, Fill Transparency, Fill Style, Hatch Angle, Hatch Width, Outline Color, Outline Transparency, Outline Width, Dash Array, Blur |
| Images / Icons | Images - Configuration | Image URL, Text or Icon Path, Icon Text Color, Icon / Background Color, Icon Background Transparency, Image Rotation (Icon Rotation for icons), Image Width (Icon Size for icons), Image Height, Transparency, Include in Auto Zoom, Include Tooltip, Selectable |
| Heatmap | Heatmap - Configuration | Include in Auto Zoom |
| Cells | Cells - Configuration | Resolution, Start Resolution, Start Resolution Zoom Level, End Resolution, End Resolution Zoom Level, Include in Zoom, Selectable |
| Cells | Cells - Formatting | Fill Color, Min Value, Mid Value, Max Value, Extrusion Start Height, Extrusion End Height. With Use Power BI Formatting on: Outline Color, Outline Transparency, Fill Transparency |
| 3D columns | Columns - Configuration | Include in Zoom, Allow Selection, Include Tooltip |
| 3D columns | Columns - Formatting | Base Height, Width, Color |
| Lines | Lines - Configuration | Include in Auto Zoom, Include Tooltip, Selectable, Include circle(s) at:, and the image URL, rotation, width, height and transparency of the start and end images |
| Lines | Lines - Formatting | Route Name, Color, Weight for Flow, Amplitude, Dash Array, Dash Animation Speed, Include Line Symbol (Straight / Shortest only), Line Symbol Text, Line Symbol Color, Line Symbol Size, Line Symbol Offset, Line Symbol Repeat, Symbol Halo Color, Symbol Halo Width, Symbol Halo Blur. For line shapes other than Flow, Smoothed Flow, Flow Arcs and Flow Tree, also Transparency, Width and Outline Blur |
| Shapes (from data) | Shapes (from data) - Configuration | Include in Auto Zoom, Include Tooltip, Selectable, Circle Size, Image URL, Image Size, Image Rotation, Icon Name, Icon Size, Icon Color, Polygon Extrusion Base Height, Polygon Extrusion Height, Linestring Shape, Route Name, and the image URL, rotation, width and height of the linestring start and end images |
| Shapes (from data) | Shapes (from data) - Formatting | Fill Color, Fill Transparency, Fill Style, Hatch Angle, Hatch Width, Pattern / Image URL, Outline Color, Outline Transparency, Outline Width, Outline Blur, Dash Array, Dash Animation Speed, Include Line Symbol, Line Symbol Text, Line Symbol Color, Line Symbol Size, Line Symbol Offset, Line Symbol Repeat, Symbol Halo Color, Symbol Halo Width, Symbol Halo Blur |
| Shapes (from files) | Configuration group | File or Service Link (GeoJSON / KML File URL in 1.1.0.9 and earlier), Property to Match to Feature Reference Field (when it is a text box), Visible, Include Tooltip, Include in Auto Zoom, Selectable, Circle Size, Polygon Extrusion Height |
| Shapes (from files) | Fill and outline groups | Fill Color, Fill Transparency, Fill Style, Hatch Angle, Hatch Width, Pattern / Image URL, Outline Color, Outline Transparency, Outline Width, Dash Array |
| Vector Tiles / Tilesets | Configuration group | Vector Tile XYZ URL, Property to Match, Layer Name(s), Visible, Include Tooltip, Include in Auto Zoom, Selectable |
| Vector Tiles / Tilesets | Formatting groups | Fill Color, Fill Transparency, Outline Color, Outline Transparency, Outline Width, Dash Array, Circle Radius, Extrusion Height, Unmatched Outline Width |
| ArcGIS layer bound to data | ArcGIS Layer - Configuration | ArcGIS Layer URL, Property to Match (when it is a text box), Visible, ArcGIS SQL WHERE Clause, Include Tooltip, Include in Auto Zoom, Selectable |
| ArcGIS layer bound to data | ArcGIS Layer - Formatting | Fill Color, Fill Transparency, Outline Color, Outline Transparency, Outline Width, Dash Array |
| Catalog layers | The layer's own group in Catalog | Layer Visible, Selected Variant, the layer's filters, Color Data Field, Extrusion Data Field, Fill Color, Outline Color, Extrusion Height, Z Index |
Line Shape in Lines - Formatting does not accept conditional formatting. Each Lines layer draws one line shape.
Labels, legend and selection
| Card | Group | Settings with fx |
|---|---|---|
| Labels | Content | Display Label, Label Text or Body Text, Title Text, Image, Footer Text |
| Labels | Style | Text Color |
| Labels | Container, Halo or Card | Display Container, the fill, tint or halo color, Transparency, Border Color, Border Width, Border Radius |
| Labels | Placement | Position |
| Legend | Legend labels | The description of each layer |
| Legend | Conditional formatting legends | The gradient field of each layer |
| Selection | Map Location | Longitude Field to Slice, Latitude Field to Slice |
Reference layers and basemap
| Layer | Settings with fx |
|---|---|
| File reference layers | URL, Filter Value, Label Property Name, Visible, Fill Color, Property for Fill Color, Outline Color, Property for Outline Color, and the start, mid and end values of a gradient |
| Vector Tiles reference layer | URL of the style JSON file, Layer Names, Filter Value |
| Raster reference layers | URL template for tile server, Visible |
| WMS reference layers | Visible, Style (optional), CQL Filter (optional), Custom Parameter Value (optional). WMS Server URL and Layer when the layer is entered by hand |
| ArcGIS reference layers | ArcGIS Layer URL, Visible, SQL WHERE Clause |
| Map Labels | Language |
| Basemap, Style group | Language, and Style URL (Maplibre Style Specification File) when Map Style is Custom Style URL |
| Hill Shading and 3D Terrain | Custom Raster URL |
| Map | Zoom Level When Single Item |
The controls, the legend's layout, the selection tools, the selection transparencies and the ArcGIS credentials do not accept conditional formatting. The position of reference layer labels does not accept it either.
Tips and limits
- A measure used with Field value must return the type the setting expects: a color, a number, text, or "Yes" or "No".
- If a setting driven by fx seems to be ignored, check the value Power BI returns. Copy the visual, change the copy to a table, and add the measure to it.
- Cells aggregated from coordinates take their colors from the layer's own color scale. Per-row colors from conditional formatting apply to cells drawn from cell IDs, with Use Power BI Formatting on.
- A Flow Tree takes one color per origin, from the first row of that origin.