Skip to main content
cancel
Showing results for
Search instead for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Frequent Visitor

Return Text column based on other column condition

Hi, I'm a noobie to DAX and need help. I have a table with product names and store wise sales.

I want to see a visual matrix table where the prodnames should be displayed if either store 1 or store 2 has sales. If there's no sale in either of the store for that prodname, it shouldn't appear in the table. Please help me how to do this.

 prodname store1 store2 store 3 store 4 prd1 100 80 26 prd2 60 7 212 prd3 50 prd4 66 29 prd5 81 0 23 prd6 28 68 prd7 118 11

OUTPUT

 prd# store1 store2 store 3 store 4 prd1 100 80 26 prd2 60 7 212 prd3 50 prd5 81 0 23 prd7 118 11
1 ACCEPTED SOLUTION
Community Support

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 Zhou

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

2 REPLIES 2
Community Support

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 Zhou

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Super User

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.

Helpful resources

Announcements

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Top Solution Authors
Top Kudoed Authors