Forum Discussion
Return Text column based on other column condition
- Anonymous3 years ago
Hi Hemanth96 ,
Here I suggest you to create measures by dax and add measures into visual level filter to filter your visual.
Measure is based on your table.
Table1:
Measure 1 = IF(ISBLANK(SUM('Table'[store1]))&& ISBLANK(SUM('Table'[store2])),0,1)Table2:
Measure 2 = VAR _STORE1 = CALCULATE(SUM('Table (2)'[Value]),FILTER('Table (2)','Table (2)'[Attribute] = "store 1")) VAR _STORE2 = CALCULATE(SUM('Table (2)'[Value]),FILTER('Table (2)','Table (2)'[Attribute] = "store 2")) RETURN IF(ISBLANK(_STORE1)&&ISBLANK(_STORE2),0,1)Create visual by columns , add measure into visual level filter and set it to show items when value =1.
Result is as below.
Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
You didn't specify if you need this in Power Query or Power BI. Here is a Power Query option.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("TY2xDcAgDARXiVxTYBOMMwuiywBR9i/CB1ui+Jf8p5N7p+e9mRJxzrMNdcyI0kg/FF8UqAGxBCvzrKGsODm3URXWFaj6bHgLWUogPTZNDK4Fa9iYzSnzejc+", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [prodname = _t, store1 = _t, store2 = _t, #"store 3" = _t, #"store 4" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"prodname", type text}, {"store1", Int64.Type}, {"store2", Int64.Type}, {"store 3", Int64.Type}, {"store 4", Int64.Type}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each [store1] ?? 0 +[store2] ?? 0 ),
#"Changed Type1" = Table.TransformColumnTypes(#"Added Custom",{{"Custom", Int64.Type}}),
#"Filtered Rows" = Table.SelectRows(#"Changed Type1", each ([Custom] <> 0))
in
#"Filtered Rows"
How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done".
Note: Data like this should be unpivoted before being loaded into Power BI.