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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
b_steward_2024
Regular Visitor

Using a filter to filter on several columns with similar values

I have a table that looks similar to the following data:

 

Name, Order_ID, Items_1_Name, Items_1_Quantity, Items_2_Name, Items_2_Quantity, Items_3_Name, Items_3_Quantity, Items_4_Name, Items_4_Quantity

 

Some rows will have blanks for some of the items columns depending on if the order has more than 1 type of item, and the same item can be in different columns. I'd like to create a filter that scans each of the Items_Name columns and filters on the item, so it only returns the items selected instead of needing to create 4 different filters to filter the same value. How can I do this?

2 ACCEPTED SOLUTIONS
AnalyticsWizard
Solution Supplier
Solution Supplier

@b_steward_2024 

To create a filter that scans each of the Items_Name columns and filters on the item, you can use Power BI’s built-in features. Let’s break down the steps:

  1. Unpivot Columns:

    • In Power Query Editor, select the columns Items_1_Name, Items_2_Name, Items_3_Name, and Items_4_Name.
    • Right-click and choose Unpivot Columns. This will transform your data into a more manageable structure.
  2. Create a New Column:

    • In the transformed table, you’ll have two new columns: Attribute and Value.
    • Rename these columns to something more meaningful (e.g., Item_Type and Item_Name).
  3. Create a Slicer:

    • Go back to your report canvas.
    • Create a slicer using the Item_Name column.
    • This slicer will allow you to filter on the items you want.
  4. Apply the Filter:

    • Use the slicer to select the specific items you want to filter.
    • The visualizations in your report will automatically adjust based on the selected items.
  5. Result:

    • You now have a single slicer that filters across all the Items_Name columns, eliminating the need for separate filters.

View solution in original post

Bipin-Lala
Solution Supplier
Solution Supplier

Hi @b_steward_2024,

Assuming I understood your requirements correctly, I believe you require a Master Item List that can be used to filter your existing tables. We can achieve this using the following steps - 

 

Taking the below sample dataset as an example

BipinLala_0-1711565963479.png

  • Create a reference (Master_Item_list) of the existing table, so that you can do your transformations on it without disturbing the original table (Samplel_ItemNames)
  • Remove the quantity-related columns as they are not necessary for creating a master item list.

BipinLala_1-1711566111367.png

  • Use the Unpivot Column in the Transform tab to translate data into attribute-value pairs, making it easy for us to create a master list

BipinLala_2-1711566209738.png

  • You can remove the attribute column since that is not required.

Once the transformations are applied and tables are available for building visuals, complete the below steps - 

  • Create a relationship between the 2 tables, Sample_ItemNames and Master_Item_List on the Order_ID column. Keep the filter direction to both sides

BipinLala_3-1711566377104.png

  • This will allow us to use the slicer created from Master_Item_List to filter your original table.
  • Create the table and slicer visuals and voila! It should work.

Filtering examples

BipinLala_6-1711566544176.png

 

BipinLala_4-1711566480967.pngBipinLala_5-1711566494858.png

Let me know if this helps or if you have any other requirements!

 

View solution in original post

4 REPLIES 4
Bipin-Lala
Solution Supplier
Solution Supplier

Hi @b_steward_2024,

Assuming I understood your requirements correctly, I believe you require a Master Item List that can be used to filter your existing tables. We can achieve this using the following steps - 

 

Taking the below sample dataset as an example

BipinLala_0-1711565963479.png

  • Create a reference (Master_Item_list) of the existing table, so that you can do your transformations on it without disturbing the original table (Samplel_ItemNames)
  • Remove the quantity-related columns as they are not necessary for creating a master item list.

BipinLala_1-1711566111367.png

  • Use the Unpivot Column in the Transform tab to translate data into attribute-value pairs, making it easy for us to create a master list

BipinLala_2-1711566209738.png

  • You can remove the attribute column since that is not required.

Once the transformations are applied and tables are available for building visuals, complete the below steps - 

  • Create a relationship between the 2 tables, Sample_ItemNames and Master_Item_List on the Order_ID column. Keep the filter direction to both sides

BipinLala_3-1711566377104.png

  • This will allow us to use the slicer created from Master_Item_List to filter your original table.
  • Create the table and slicer visuals and voila! It should work.

Filtering examples

BipinLala_6-1711566544176.png

 

BipinLala_4-1711566480967.pngBipinLala_5-1711566494858.png

Let me know if this helps or if you have any other requirements!

 

Thanks for the in depth answer, this was exctly what I was looking for. Very helpeful and useful 😄

AnalyticsWizard
Solution Supplier
Solution Supplier

@b_steward_2024 

To create a filter that scans each of the Items_Name columns and filters on the item, you can use Power BI’s built-in features. Let’s break down the steps:

  1. Unpivot Columns:

    • In Power Query Editor, select the columns Items_1_Name, Items_2_Name, Items_3_Name, and Items_4_Name.
    • Right-click and choose Unpivot Columns. This will transform your data into a more manageable structure.
  2. Create a New Column:

    • In the transformed table, you’ll have two new columns: Attribute and Value.
    • Rename these columns to something more meaningful (e.g., Item_Type and Item_Name).
  3. Create a Slicer:

    • Go back to your report canvas.
    • Create a slicer using the Item_Name column.
    • This slicer will allow you to filter on the items you want.
  4. Apply the Filter:

    • Use the slicer to select the specific items you want to filter.
    • The visualizations in your report will automatically adjust based on the selected items.
  5. Result:

    • You now have a single slicer that filters across all the Items_Name columns, eliminating the need for separate filters.

Thanks for the answer, this was also extremely helpful

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.