Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Need help with bar chart

Hi, 

 

New to Power BI here. 

 

If I have 20 Likert scale survey questions, can I create a dynamic bar chart that displays the agree/disagree response count for one question at a time? i.e. if I choose "question1" it will show the response counts for question1 but no other questions. 

 

And then I can select "question2" to view only the response counts for question 2 etc.  Example image of graph below. 

 

I'm not sure whether to use a slicer or filter?

 

Thank you kindly

Ang

  • itsmebvk's avatar
    itsmebvk
    6 years ago

    Anonymous 

     

    Please watch attached video for steps. *** Note: there are many ways of doing it.

     

10 Replies

  • itsmebvk's avatar
    itsmebvk
    Icon for Continued Contributor rankContinued Contributor

    Anonymous 

     

    There are many of ways of doing it. I am not infront of system, but I belive you can create two measures using follwing expression.

     

    Like Count =
    SWITCH(
    SELECTEDVALUE([survey questions])
    ,1, CALCULATE(COUNT([Like and Dislike column]),FILTER(Table,[Like and Dislike column] = "Like" && [survey questions]=1))
    ,2, CALCULATE(COUNT([Like and Dislike column]),FILTER(Table,[Like and Dislike column] = "Like" && [survey questions]=2))
    ,3, CALCULATE(COUNT([Like and Dislike column]),FILTER(Table,[Like and Dislike column] = "Like" && [survey questions]=3))
    , CALCULATE(COUNT([Like and Dislike column]),FILTER(Table,[Like and Dislike column] = "Like" && [survey questions]=1))
    )

     

    DisLike Count =
    SWITCH(
    SELECTEDVALUE([survey questions])
    ,1, CALCULATE(COUNT([Like and Dislike column]),FILTER(Table,[Like and Dislike column] = "DisLike" && [survey questions]=1))
    ,2, CALCULATE(COUNT([Like and Dislike column]),FILTER(Table,[Like and Dislike column] = "DisLike" && [survey questions]=2))
    ,3, CALCULATE(COUNT([Like and Dislike column]),FILTER(Table,[Like and Dislike column] = "DisLike" && [survey questions]=3))
    , CALCULATE(COUNT([Like and Dislike column]),FILTER(Table,[Like and Dislike column] = "DisLike" && [survey questions]=1))
    )

     

     

    Use them in chart. Please let me know how it goes.

    • Anonymous's avatar
      Anonymous
      Not applicable

      itsmebvk 

      Hey thanks for your reply. I'm really very new to Power BI and coding, would it be possible to break down the instructions further or link a video tutorial that demonstartes how to do this?

       

      Thanks very much. 

      • itsmebvk's avatar
        itsmebvk
        Icon for Continued Contributor rankContinued Contributor

        Anonymous  I am sorry I am not sure how to create video and link. Please follow below steps.

         

        1)Assume that you have following data

         

         

        2)Then Open Power BI Desktop, create a mesure as follows

         

         

        3) Use following expression

         

        Measure = count(Sheet1[Answer])
         
        4)Then select Answers and New Measure columns to chart as highlighted below
         
         
         
        5) Then select slicer as highlighted in 5step, then assign Question column to this.
         
        Now should be able to play with it. 
         
         
  • VijayP's avatar
    VijayP
    Icon for Community Champion rankCommunity Champion
    I have used a slicer and connected the slicer to the Chart with SELECTEDVALUE function. if you find this as solution , I can share the Video to understand how to do it!!