The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Id want to display a tile slicer with each button representing a status from a rag screen red\amber\green. I had a dim mentions called DIM_SWRAGStatus which contains SWRagstatusID and SWRAGstatus. The ID field links back to fact table where these is a also SWRagstatusID per ticket. ID field has value of 1,2 or 3. I also have caculated groups so have to have implicte measures.
While I know how to change the color and how to point it measure. I'm unable to get it to just display the 3 colors in one slicer visual.
I've tried using SelectedValue but that only works when a value is selected I want to have default to the correct color. The only Way so far I can is either having 3 different slicers each set to one of the values and no interatctoins between them or Buttons which set the filter context.
Is there any way I can do this using just one slicer.
Solved! Go to Solution.
Hi @locka ,
To create a tile slicer in Power BI that displays Red, Amber, and Green (RAG) statuses in a single visual with appropriate color formatting, you can leverage either Field Parameters or a custom table with calculated measures. The goal is to have a slicer that shows the three color statuses as selectable buttons, applies the correct color formatting, and filters your fact table based on the selected status.
First, let’s address the approach using Field Parameters, a feature in Power BI that allows you to create dynamic slicers. You can create a parameter that holds the three color values—Red, Amber, and Green—along with their corresponding IDs from your DIM_SWRAGStatus table.
To create a field parameter, go to the Modeling tab in Power BI Desktop and select New Parameter > Fields. Use the following DAX code to define the parameter:
SWRAG Status Slicer = {
("Red", "DIM_SWRAGStatus[SWRAGstatus]", 1),
("Amber", "DIM_SWRAGStatus[SWRAGstatus]", 2),
("Green", "DIM_SWRAGStatus[SWRAGstatus]", 3)
}
This will generate a slicer that includes the three statuses as selectable options. Add this parameter to a slicer visual and change the slicer style to Tile. You can then apply conditional formatting to the slicer tiles by mapping each status to its corresponding color. For example, Red can be mapped to SWRAGstatusID = 1, Amber to SWRAGstatusID = 2, and Green to SWRAGstatusID = 3.
Next, modify your DAX measures to respect the slicer’s selection by using the SELECTEDVALUE function. This ensures that the slicer selection dynamically filters the fact table based on the selected RAG status. Here’s an example of a measure that counts tickets based on the selected status:
Filtered Tickets =
CALCULATE(
COUNT('FactTable'[TicketID]),
'DIM_SWRAGStatus'[SWRAGstatusID] = SELECTEDVALUE('SWRAG Status Slicer'[SWRAGstatusID])
)
Alternatively, if you prefer a more manual approach without using field parameters, you can create a custom table directly in Power BI using the DATATABLE function. This approach allows you to manually define the RAG statuses and their corresponding IDs, which can be used in your slicer visual. Use the following DAX code to create the custom table:
SWRAGStatusTable =
DATATABLE(
"SWRAGstatus", STRING,
"SWRAGstatusID", INTEGER,
{
{"Red", 1},
{"Amber", 2},
{"Green", 3}
}
)
Once the table is created, add it to a slicer visual and apply conditional formatting to each tile to display the correct color. You can then use the same SELECTEDVALUE logic in your measures to filter the fact table based on the selected RAG status.
Lastly, if you encounter issues with SELECTEDVALUE returning blank when no value is selected, consider using a default value in your measure. For example:
Selected Status =
IF(
ISBLANK(SELECTEDVALUE('SWRAGStatusTable'[SWRAGstatusID])),
1, // Default to Red if no selection
SELECTEDVALUE('SWRAGStatusTable'[SWRAGstatusID])
)
By using these methods, you can achieve a clean and user-friendly RAG tile slicer that dynamically filters your data and enhances the interactivity of your Power BI report.
Best regards,
Hi @locka ,
To create a tile slicer in Power BI that displays Red, Amber, and Green (RAG) statuses in a single visual with appropriate color formatting, you can leverage either Field Parameters or a custom table with calculated measures. The goal is to have a slicer that shows the three color statuses as selectable buttons, applies the correct color formatting, and filters your fact table based on the selected status.
First, let’s address the approach using Field Parameters, a feature in Power BI that allows you to create dynamic slicers. You can create a parameter that holds the three color values—Red, Amber, and Green—along with their corresponding IDs from your DIM_SWRAGStatus table.
To create a field parameter, go to the Modeling tab in Power BI Desktop and select New Parameter > Fields. Use the following DAX code to define the parameter:
SWRAG Status Slicer = {
("Red", "DIM_SWRAGStatus[SWRAGstatus]", 1),
("Amber", "DIM_SWRAGStatus[SWRAGstatus]", 2),
("Green", "DIM_SWRAGStatus[SWRAGstatus]", 3)
}
This will generate a slicer that includes the three statuses as selectable options. Add this parameter to a slicer visual and change the slicer style to Tile. You can then apply conditional formatting to the slicer tiles by mapping each status to its corresponding color. For example, Red can be mapped to SWRAGstatusID = 1, Amber to SWRAGstatusID = 2, and Green to SWRAGstatusID = 3.
Next, modify your DAX measures to respect the slicer’s selection by using the SELECTEDVALUE function. This ensures that the slicer selection dynamically filters the fact table based on the selected RAG status. Here’s an example of a measure that counts tickets based on the selected status:
Filtered Tickets =
CALCULATE(
COUNT('FactTable'[TicketID]),
'DIM_SWRAGStatus'[SWRAGstatusID] = SELECTEDVALUE('SWRAG Status Slicer'[SWRAGstatusID])
)
Alternatively, if you prefer a more manual approach without using field parameters, you can create a custom table directly in Power BI using the DATATABLE function. This approach allows you to manually define the RAG statuses and their corresponding IDs, which can be used in your slicer visual. Use the following DAX code to create the custom table:
SWRAGStatusTable =
DATATABLE(
"SWRAGstatus", STRING,
"SWRAGstatusID", INTEGER,
{
{"Red", 1},
{"Amber", 2},
{"Green", 3}
}
)
Once the table is created, add it to a slicer visual and apply conditional formatting to each tile to display the correct color. You can then use the same SELECTEDVALUE logic in your measures to filter the fact table based on the selected RAG status.
Lastly, if you encounter issues with SELECTEDVALUE returning blank when no value is selected, consider using a default value in your measure. For example:
Selected Status =
IF(
ISBLANK(SELECTEDVALUE('SWRAGStatusTable'[SWRAGstatusID])),
1, // Default to Red if no selection
SELECTEDVALUE('SWRAGStatusTable'[SWRAGstatusID])
)
By using these methods, you can achieve a clean and user-friendly RAG tile slicer that dynamically filters your data and enhances the interactivity of your Power BI report.
Best regards,