Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hello,
Can anyone help me with a solution to this?
We have built a Matrix report but need to filter rows based on the value of at least two column in a matrix.
Vendor | Corporate | Energy | Defence |
Supplier 1 | Z04M | Z06M | |
Supplier 2 | Z06M | ||
Supplier 3 | Z06M | Z06M | |
Supplier 4 | Z09M | ||
Supplier 5 | Z09M | Z03M |
We want to keep only Supplier 1, 3 & 5.
(and the dream could be only keep Supplier 1 & 5 because value are not the same)
Thanks for your help,
Julian.
Solved! Go to Solution.
@JuliCraps First your table needs to be transformed for better design, basically unpivot your table, to unpivot follow these steps:
- transform data
- select vendor column
- right-click, unpivot other columns it will add two columns, attribute, and value, rename these as per your requirement
- filter blank values rows (we don't need these)
- close and apply
To visualize,
- matrix visual:
- add vendor on rows,
- add attribute on columns
- add value on values section
Add the following measure:
Count Measure = CALCULATE ( DISTINCTCOUNT ( Vendor[Value] ), ALLEXCEPT ( Vendor, Vendor[Vendor] ) )
and use this measure as visual level filter on above matrix visual
and here is the result
Here is M script to unpivot, create a blank query and in advanced editor paste the following code:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCi4tKMjJTC1SMFTSUYoyMPEFU2YgSkEpVgdJgRGyDIasMVQYqgJMoSgwAYta4tBuipCNMjAGUUqxsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Vendor = _t, Corporate = _t, Energy = _t, Defence = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Vendor", type text}, {"Corporate", type text}, {"Energy", type text}, {"Defence", type text}}),
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Vendor"}, "Attribute", "Value"),
#"Filtered Rows" = Table.SelectRows(#"Unpivoted Other Columns", each ([Value] <> "" and [Value] <> " "))
in
#"Filtered Rows"
I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Filter on Energy <> Blank (Visual level)
Or have a measure like
Calculate(Sum(Table[Value]),not(isblank(Table[Energy])))
@JuliCraps First your table needs to be transformed for better design, basically unpivot your table, to unpivot follow these steps:
- transform data
- select vendor column
- right-click, unpivot other columns it will add two columns, attribute, and value, rename these as per your requirement
- filter blank values rows (we don't need these)
- close and apply
To visualize,
- matrix visual:
- add vendor on rows,
- add attribute on columns
- add value on values section
Add the following measure:
Count Measure = CALCULATE ( DISTINCTCOUNT ( Vendor[Value] ), ALLEXCEPT ( Vendor, Vendor[Vendor] ) )
and use this measure as visual level filter on above matrix visual
and here is the result
Here is M script to unpivot, create a blank query and in advanced editor paste the following code:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCi4tKMjJTC1SMFTSUYoyMPEFU2YgSkEpVgdJgRGyDIasMVQYqgJMoSgwAYta4tBuipCNMjAGUUqxsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Vendor = _t, Corporate = _t, Energy = _t, Defence = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Vendor", type text}, {"Corporate", type text}, {"Energy", type text}, {"Defence", type text}}),
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Vendor"}, "Attribute", "Value"),
#"Filtered Rows" = Table.SelectRows(#"Unpivoted Other Columns", each ([Value] <> "" and [Value] <> " "))
in
#"Filtered Rows"
I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Thanks lot @parry2k , it's perfect 🤗.
(Apologies, my initial source was not build as i explain, i appreciate your recommandation).
Hello @amitchandak,
the filter is not based on "Energy" column but for rows with a value in at least 2 columns.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
112 | |
99 | |
73 | |
72 | |
49 |
User | Count |
---|---|
145 | |
109 | |
109 | |
90 | |
64 |