To build hierarchy in Power BI, follow these steps:
Step 1: Prepare your data
Ensure that your data contains the necessary fields that define the hierarchy. For example, if you have a sales dataset with columns for Product, Category, and Subcategory, you can use these fields to create a hierarchy.
Step 2: Create a hierarchy
- Open Power BI Desktop and import your data.
- In the “Fields” pane on the right, select the fields you want to include in your hierarchy (e.g., Product, Category, Subcategory).
- Right-click on one of the selected fields and choose “Create Hierarchy.”
- Name your hierarchy by double-clicking on the default name and entering a new one (e.g., “Product Hierarchy”).
- Drag and drop the remaining fields into the hierarchy in the desired order (e.g., Category below Product, Subcategory below Category).
Step 3: Use the hierarchy in visualizations
Once you have created the hierarchy, you can use it in various visualizations to analyze your data in a hierarchical manner. For example, you can use a hierarchy slicer to easily filter data by different levels of the hierarchy.
Example:
Let’s say you have a sales dataset with the following fields: Product, Category, and Subcategory. By creating a hierarchy with these fields, you can visualize and explore your sales data at different levels of granularity. For instance, you can view sales by product, drill down to see sales by category, and further drill down to see sales by subcategory.