Forum Discussion

AlinaJa's avatar
AlinaJa
Helper I
6 years ago
Solved

Dynamic Target Line with bar chart

Hi all,

 

I am looking for a way to create a stacked bar chart with a target line. The target line has to be dynamic depending on the filter criteria selected. 

At the moment, I have two different tables: The first one contains the actual inventory data per Week and company location. The second table contains the inventory target per company location. This goal is the same for every week. How do I combine these two tables into a graph with bars (the actual inventory per week) and a line (inventory target, same for every week)? The x-axis is supposed to display the months and the y-axix the inventory value. It has to be possible to filter/slice by company location and then the visual needs to show the target for that specific location. 

 

Thanks in advance.

 

Alina

  • AlinaJa Maybe you could post photo or sample pbix? I don't understand what isn't working.

     

     

    That is what I get when I use your sample data, with Target[Location] in the slicer, and Target[Location] in the column series of the chart (though maybe not needed).

     

    If no location is selected, the target will add up to sum of all locations, but when location is selected it behaves as expected. 

     

    Is that what you're looking for? 

12 Replies

    • AlinaJa's avatar
      AlinaJa
      Helper I

      Thank you for you quick response. amitchandak 

       

      I am quite new to the Power Bi topic.

      What exactly do you mean by an avg measure with all or allselected? Could you give me an example how a measure like this could look like?

      • amitchandak's avatar
        amitchandak
        Super User

        AlinaJa , Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

         

        Example

        CALCULATE(Average(Sales[Sales Amount]),all(Sales))

         

        CALCULATE(Average(Sales[Sales Amount]),allselected(Sales))

         

  • AllisonKennedy's avatar
    AllisonKennedy
    Community Champion
    AlinaJa I would recommend using the line and clustered column chart. That way you can add the measure/column for your target to the Line Values, and the Actuals to the Column Values. Then both will update with filter selection.
    • AlinaJa's avatar
      AlinaJa
      Helper I

      AllisonKennedy  The problem is that if I add the column from my target table as line values, it always gives me the sum of all targets. No matter which location I select.

      If I add the target as a column to the other table and then add it to the graph as the line value, I have to choose whether I want to use the average/sum/Min/Max/... But I don't want any of these, I just want the actual value for this location. 

      • AllisonKennedy's avatar
        AllisonKennedy
        Community Champion
        AlinaJa This sounds like it might be related to your data model/relationships. Are you able to post a screenshot of that view or provide an overview with confidential info removed?