Forum Discussion

H-D's avatar
H-D
New Member
4 years ago
Solved

Adding Slicer by Pie Chart Value

Hi, 

 

I have a dataset with various columns, to simplify for the core purpose of my question, the 4 relevant columns are:

1) Building Name

2) Vacant/occupied

3) # of Units

4) Area (Sq. Ft.) 

The same building name has both vacant and occupied units/areas.

I created a power bi pie chart with "Vacant/occupied" and filtered to a specific building name. My problem comes in with the values, if I put "# of Units" in the values field, I'll get a pie chart with number and percentage of units occupied and number and percentage of units vacant and if I put "Area (Sq. Ft.)", I'll get the same but with area instead of number of units - If I add both columns to my values field there's too much data on the chart. Ideally, I want a slicer that allows the user to toggle between "# of Units" or "Area (Sq. Ft." and see the relevant data. I tried searching the forums but I can't find a solution to my problem, I tried to unpivot my "# of units" and "Area (Sq. Ft.)" columns but then my pie charts all get ruined because my sum of units and sum of areas columns disappear. Please help?

  • Hi,

    - In Power Query, Create a duplicated of the current table (...(2))

    - In the main table Create a column (name itFlag) and put the "Area (Sq. Ft.)" fix value in it

    - Create a copy of the "Area" column 

    - in the duplicate table, do it based on the "# of units" :

    - Append both tables :

    - Add the new Column for the Append table as below :

    = Table.AddColumn(Source, "Value(Area-#Unit)", each (if [#"Area (Sq. Ft.) - Copy"] <> null then [#"Area (Sq. Ft.) - Copy"] else 0) + (if[#"# of Units - Copy"] <> null then [#"# of Units - Copy"] else 0))

    - Now in Power BI :

    - Create Slicer based on the Flag field :

    - And pie Chart on 'Vacant/Occupied' and 'Value(Area-#uint)

     

     

2 Replies

  • MahyarTF's avatar
    MahyarTF
    Memorable Member

    Hi,

    - In Power Query, Create a duplicated of the current table (...(2))

    - In the main table Create a column (name itFlag) and put the "Area (Sq. Ft.)" fix value in it

    - Create a copy of the "Area" column 

    - in the duplicate table, do it based on the "# of units" :

    - Append both tables :

    - Add the new Column for the Append table as below :

    = Table.AddColumn(Source, "Value(Area-#Unit)", each (if [#"Area (Sq. Ft.) - Copy"] <> null then [#"Area (Sq. Ft.) - Copy"] else 0) + (if[#"# of Units - Copy"] <> null then [#"# of Units - Copy"] else 0))

    - Now in Power BI :

    - Create Slicer based on the Flag field :

    - And pie Chart on 'Vacant/Occupied' and 'Value(Area-#uint)

     

     

  • v-jingzhang's avatar
    v-jingzhang
    Community Support

    Hi H-D

     

    You can use the Field parameter feature in Power BI. It is a preview feature at present so you need to enable it from File > Options > Preview Feature to use it. You can create a field parameter, add "# of Units" and "Area (Sq. Ft.)" to it. Then use a slicer to switch the fields under this parameter. 

    Let report readers use field parameters to change visuals (preview) - Power BI | Microsoft Docs

     

    Best Regards,
    Community Support Team _ Jing
    If this post helps, please Accept it as Solution to help other members find it.