Forum Discussion
Poornima2023
11 months agoHelper I
Help with conditional formatting in power bi
Hi I need help with formatting of matrix table like below.
- 11 months ago
Hi Poornima2023 ,
Finally I achieved this using SVG:
This svg feature helps to give conditional formatting based on the data we have.
Here is the mcode that i used:let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wck0sLlHSUXLKKM0rS8xLLc4oTyxSitWJVvLLLyrJAMo4ZyTmpWSmJxZlgIWD80uhwql5eYmZSrGxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Region = _t, #"Branch " = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Region", type text}, {"Branch ", type text}}), #"Added Conditional Column" = Table.AddColumn(#"Changed Type", "svg", each if [Region] = "East" then "data:image/svg+xml;utf8," & "<svg width='200' height='100' xmlns='http://www.w3.org/2000/svg'>" & "<rect x='10' y='10' width='180' height='80' fill='#2196F3' stroke='#333' stroke-width='2' rx='10' ry='10'/>" & "<text x='100' y='55' font-size='20' font-family='Arial' fill='white' text-anchor='middle' dominant-baseline='middle'>East</text>" & "</svg>" else if [Region] = "North" then "data:image/svg+xml;utf8," & "<svg width='200' height='100' xmlns='http://www.w3.org/2000/svg'>" & "<rect x='10' y='10' width='180' height='80' fill='#4CAF50' stroke='#333' stroke-width='2' rx='10' ry='10'/>" & "<text x='100' y='55' font-size='20' font-family='Arial' fill='white' text-anchor='middle' dominant-baseline='middle'>North</text>" & "</svg>" else if [Region] = "South" then "data:image/svg+xml;utf8," & "<svg width='200' height='100' xmlns='http://www.w3.org/2000/svg'>" & "<rect x='10' y='10' width='180' height='80' fill='#FF9800' stroke='#333' stroke-width='2' rx='10' ry='10'/>" & "<text x='100' y='55' font-size='20' font-family='Arial' fill='white' text-anchor='middle' dominant-baseline='middle'>South</text>" & "</svg>" else null) in #"Added Conditional Column"Does this resolve your issue? let me know
Best regards,
Poornima2023
11 months agoHelper I
Please help. Also note its not table its matrix.
sivarajan21
11 months agoPost Prodigy
Hi Poornima2023
Sure!
I used plotly chart using python script to achieve this
You need to just click the PY in visualization and type in below code on scripts to achieve this.
Before that do you have python installed on your machine?
Currently power bi doesn't provide formatting on all columns
Please let me know
Best Regards,