Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
axarhaan
Helper I
Helper I

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_0-1663341477329.png

 

1 ACCEPTED SOLUTION

@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.

vojtechsima_0-1663347570571.png

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

 

View solution in original post

3 REPLIES 3
vojtechsima
Memorable Member
Memorable Member

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:

vojtechsima_0-1663344115957.png

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

vojtechsima_1-1663344208456.png

With total ON:

vojtechsima_2-1663344220518.png

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:

vojtechsima_3-1663344327556.png

 



 

@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.

@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.

vojtechsima_0-1663347570571.png

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

 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.