How to create conditional bookmarks in Power BI: step by step
This tutorial shows how to create conditional bookmarks in Power BI to automatically switch between visual states depending on a condition (for example, show details when a measure exceeds a threshold). It is useful to improve the user experience and reduce the number of clicks when presenting different scenarios or levels of detail.
Prerequisites
- Power BI Desktop (recent version).
- A simple model with at least one fact table and one dimension (you can use Excel/CSV).
- Basic knowledge of DAX and Bookmarks in Power BI.
Step 1: Prepare the visuals that represent the states
Decide which states you want to toggle (for example: Summary View and Detail View). Create the necessary visuals on a page: an aggregated visual (cards/summary tables) and a detailed visual (table/Matrix). Position them clearly and, if you want, add different aesthetic elements for each state.
Step 2: Create a measure that defines the condition
To make the bookmark conditional, we need a measure that returns 1 or 0 depending on the condition. Example: show Detail when TotalSales is greater than 100000.
MostrarDetalhe =
VAR Limite = 100000
VAR TotalVendas = SUM('Vendas'[Valor])
RETURN
IF(TotalVendas > Limite, 1, 0)
Place this measure in a card visual to quickly test if it works. If the value is 1, the condition is satisfied.
Step 3: Create bookmarks for each state
Configure the visibility of the visuals to represent each state: for example, in Summary View show only the cards and hide the detailed table; in Detail View do the opposite. Then create two bookmarks (View Summary, View Detail):
- Ensure only the intended visuals are visible.
- View > Bookmarks Pane > Add. Rename to View Summary.
- Rearrange visuals and create the View Detail bookmark.
Important: in the bookmark options uncheck "Data" if you don't want to capture filters, and check "Display" (or "Visual" depending on the version) to capture the visibility of visuals.
Step 4: Create buttons and link to the bookmarks
Create two buttons (Insert > Buttons) labeled "Resumo" and "Detalhe". Select a button and, in the Action pane, choose Type = Bookmark and Bookmark = View Summary (or View Detail). Do the same for the other button. These buttons allow manual toggling between states.
Step 5: Automate the change with a measure and dynamic bookmarks
To make the change conditional and automatic, we'll use a visual that alters navigation based on the MostrarDetalhe measure. A simple technique is to create two bookmarks and use button-based navigation with a measure that defines which button is visible. First create an auxiliary table to control button visibility:
BotaoEstado =
DATATABLE(
"Estado", STRING,
{ {"Resumo"}, {"Detalhe"} }
)
Create a slicer with BotaoEstado[Estado] (it can be hidden). Then create a measure that combines the condition with the slicer selection to use in conditional formatting of the buttons (simulated visibility):
BotaoVisivel =
VAR Selecionado = SELECTEDVALUE(BotaoEstado[Estado], "Resumo")
VAR Cond = [MostrarDetalhe]
RETURN
SWITCH(Selecionado,
"Detalhe", IF(Cond = 1, 1, 0),
"Resumo", IF(Cond = 0, 1, 0),
0
)
Use this measure in conditional formatting (for example, button color or transparency) to provide visual feedback. To trigger the bookmark automatically without clicking, there is no native function that changes a bookmark with DAX; the alternative is to instruct the user to click a button that appears conditionally (via formatting) or to use selectors/Field Parameters to switch visuals dynamically. Here we simulate automation by showing only the relevant button using conditional formatting.
Step 6: Improve the experience with transparency and messages
Apply conditional formatting to the buttons' properties (fill, outline, image) using the BotaoVisivel measure: when it is 1 show normal color; when it is 0 set transparent color or reduce opacity. Add a card with a dynamic message explaining why you see detail or summary:
MensagemEstado =
IF([MostrarDetalhe]=1,
"Attention: showing details because sales exceed the threshold.",
"Showing summary. Select Detail to see more."
)
Verify the result
Test by changing the data (or applying date/customer filters) so that [MostrarDetalhe] toggles between 0 and 1. Verify that the relevant button becomes highlighted (or visible) and that, when clicking the button, the correct bookmark is applied. Also confirm the dynamic message on the card to ensure the condition is being evaluated correctly.
Conclusion
With conditional bookmarks in Power BI you can guide the user between relevant states without overloading the page with many visuals. Next steps: try to further automate with Field Parameters or use Bookmarks+Selection Pane for entire pages. Tip: always test with extreme scenarios to ensure the condition and visibility remain consistent.