Forum Discussion

axarhaan's avatar
axarhaan
Helper I
3 years ago
Solved

Count Date Value Horizontally

Hi all,

 

I am still at a early stage of learning Power Bi and I need help.

 

I am trying to create a table to get the total number of lessons attended by students. In below dataset I added 5 lessons and the date studdent attended that lesson. I want the total lessons attended at the last coulmn as displayed.

 

Please help and let me know how to get the count horizontally. Thanks in advance. 🙂

 

 

 

  • axarhaan 
    If you must, here you go.

    In Power Query, I pivoted the lessons and then in other table I grouped the count and merge it back.

    But this is not how you should use Power BI, this would be way easier in Excel.

     

3 Replies

  • Hi, axarhaan ,
    this exact view is only possible if you go against the natural law of Power BI. Which I don't recommend.
    The problem with this view is that this alone with the count is okey:

    But if you want to add the Count, it automatically builds hierarchy:

    With total ON:

    So, if you keep data in the correct form as is here (souce):

    Record ID Lesson ID Date
    1 Lesson 1 16.06.2022
    1 Lesson 2 10.06.2022
    3 Lesson 1 15.01.2022
    3 Lesson 2 22.01.2022
    3 Lesson 3 29.01.2022
    4 Lesson 1 19.05.2022
    4 Lesson 2 16.06.2022
    4 Lesson 3 17.06.2022
    5 Lesson 2 16.06.2022
    5 Lesson 3 17.06.2022
    5 Lesson 4 23.06.2022
    5 Lesson 5 25.06.2022



    You have to create an additional table for the count:

     



     
    • axarhaan's avatar
      axarhaan
      Helper I

      vojtechsima 

       

      Thank you for your reply.

       

      Keeping the data in a certain form is not in my hand. The picture I attached previously is the data format I am getting, so don't know how to build it like you suggested. And also I don't know how you are getting that Attending column says "1".

       

      If any other solution, please share. Thank you so much.

      • vojtechsima's avatar
        vojtechsima
        Super User

        axarhaan 
        If you must, here you go.

        In Power Query, I pivoted the lessons and then in other table I grouped the count and merge it back.

        But this is not how you should use Power BI, this would be way easier in Excel.