Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
1 year ago
Solved

Line & Stacked Column Chart

Hi Team,

I am using a Line & Stacked Column chart and passing 7 metrics in Column Y - axis (in image below A- G)

Now the situation is we have a slicer for Channel, and it has two options X and Y.
If channel X is selected from the slicer, Measure "F" should be displayed in the bar and, measure "G" should be displayed in the bar if the other selction is made.

Any help will be appreciated.

  • What would you like to do with A to E?


    If you are asking can you group measures then yes.
    The easiest thing to do is use a Field Parameter:
    https://learn.microsoft.com/en-us/power-bi/create-reports/power-bi-field-parameters

    Then after you have created this swap to Table view, then Right click the first column in the table and choose New Group.

    Assign each measure to the X or Y group.

    Using this in the visual will pull all the group measures through and you can filter the group to either X or Y.

  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi Anonymous 

     

    Thanks for the reply from SamWiseOwl, please allow me to add my opinion.

     

    Do you want measure A-E to be displayed all the time, and then when "X" is selected in the slicer, show measure F, and when any other option is selected, show measure G? If so, please refer to the following test:

     

    I am using the sample data from Power BI Desktop.

     

    There is another table as a slicer, and there is no relationship between the two tables. Then I created five measures.

     

     

     

    Then I created the following measure:

    Output = IF(SELECTEDVALUE('Slicer'[Slicer]) = "X", [Measure 5], [Measure 4])

     

    When I select "X", the visualization shows [Measure5], and when I select the other options, it shows [Measure4].

     

    Output:

     

    The following is the specific approach of SamWiseOwl‘s method I understand, for your reference:

     

    Select Field Parameter

     

     

    In the Table view interface, right-click Parameter and select New group.

     

    Select the corresponding measure to create a group. Here I group [Measure4] and [Measure5] separately, and then add other measures to the "Other" group. The reason is that measures that have been added to a group cannot be reused. In other words, if other measures are grouped with any measure, they cannot be displayed together with another measure.



    Output:

     

     

    Best Regards,
    Yulia Xu

     

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

5 Replies

  • Hi Anonymous 

    Could you create a measure to do this:
    Swap F and G =
    IF(
    selectedValue(table[Channel]) = "X"

    ,[measure F]

    ,[measure G]
    )

  • Anonymous's avatar
    Anonymous
    Not applicable

    SamWiseOwl Thanks for your response.

    How about other measures from A to E?
    Also these individual measures needs to be displayed in legends of the chart

    • SamWiseOwl's avatar
      SamWiseOwl
      Super User

      What would you like to do with A to E?


      If you are asking can you group measures then yes.
      The easiest thing to do is use a Field Parameter:
      https://learn.microsoft.com/en-us/power-bi/create-reports/power-bi-field-parameters

      Then after you have created this swap to Table view, then Right click the first column in the table and choose New Group.

      Assign each measure to the X or Y group.

      Using this in the visual will pull all the group measures through and you can filter the group to either X or Y.

      • Anonymous's avatar
        Anonymous
        Not applicable

        I would like to see all the measures from A to E as well apart from those two conditional measure.
        can you please share pbix file where you have implemented this?

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous 

     

    Thanks for the reply from SamWiseOwl, please allow me to add my opinion.

     

    Do you want measure A-E to be displayed all the time, and then when "X" is selected in the slicer, show measure F, and when any other option is selected, show measure G? If so, please refer to the following test:

     

    I am using the sample data from Power BI Desktop.

     

    There is another table as a slicer, and there is no relationship between the two tables. Then I created five measures.

     

     

     

    Then I created the following measure:

    Output = IF(SELECTEDVALUE('Slicer'[Slicer]) = "X", [Measure 5], [Measure 4])

     

    When I select "X", the visualization shows [Measure5], and when I select the other options, it shows [Measure4].

     

    Output:

     

    The following is the specific approach of SamWiseOwl‘s method I understand, for your reference:

     

    Select Field Parameter

     

     

    In the Table view interface, right-click Parameter and select New group.

     

    Select the corresponding measure to create a group. Here I group [Measure4] and [Measure5] separately, and then add other measures to the "Other" group. The reason is that measures that have been added to a group cannot be reused. In other words, if other measures are grouped with any measure, they cannot be displayed together with another measure.



    Output:

     

     

    Best Regards,
    Yulia Xu

     

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