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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
JonSwed
Advocate II
Advocate II

Need help grouping visitorId by session count and date

Hi all,

So I'm importing Google Analytics data and have created a new table (from another table) where I'm counting sessions by user.
This is the DAX I used to create my table:

Table = SUMMARIZE( ALL ('GA_pageviews'[hitDate_], 'GA_pageviews_Help'[fullVisitorId], 'GA_pageviews'[country_], 'GA_pageviews'[visitIdUnique_] ),

'GA_pageviews_Help'[hitDate_],
'GA_pageviews_Help'[fullVisitorId],
GA_pageviews_Help[country_],
"Count", DISTINCTCOUNT( ('GA_Hits_Mod_Pageviews_Help'[visitIdUnique_]) )
)




My table then  looks like this.

JonSwed_0-1601969024834.png


What I want to do is create a bucketed table based on this data. So I can group users by the number of sessions they have made in a given time range. Buckets like 1 - 5, 6 - 10 etc. Essentially, a histogram where the x axis will be bucketed number of sessions and the y axis will be a count of users who have made that many sessions. Time range can be changed by the user based on a slicer on the dashboard.

Many thanks for any help you can offer. 










1 ACCEPTED SOLUTION
Pragati11
Super User
Super User

Hi @JonSwed ,

 

I don't think you need a new table to create groupings in SESSION column. You can create a new column and use it for visualisation in your report.

 

sessionGrouping = IF([session] >= 1 && [session] <= 5, "1-5 Group",

                                   IF([session] >= 6 && [session] <= 10, "6-10 Group", "Above 10 Group"))

 

See the above example for column creation.

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

View solution in original post

6 REPLIES 6
JonSwed
Advocate II
Advocate II

Hi all. Again, many thanks for the help to date.

The dax code, as a measure works perfectly. When I create a table including this measure it labels the users, and their sessions, with the correct grouping. However, as a calculated column it does not work. This is my next challenge as I need to visualise this data as a histogram, rather than presenting it in a table.

The calculated column I guess is not working correctly because it is not operating on the aggregated fullvisitorIds which the measure is. As the data can be sliced by the user, and includes a filter for another dimension (country) I need this to have the dynamic capability that a measure has.

Many thanks in advance for any further help.





JonSwed
Advocate II
Advocate II

Thanks for the input guys. Unfortunately the dax solution does not seem to work. I'll be looking into it in more detail and checking out the video which was shared.

Hi @JonSwed ,

 

Doesn't seem to understand why you say that DAX is not working?

Please add details on why it's not working.

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

Pragati11
Super User
Super User

Hi @JonSwed ,

 

I don't think you need a new table to create groupings in SESSION column. You can create a new column and use it for visualisation in your report.

 

sessionGrouping = IF([session] >= 1 && [session] <= 5, "1-5 Group",

                                   IF([session] >= 6 && [session] <= 10, "6-10 Group", "Above 10 Group"))

 

See the above example for column creation.

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

I spoke too soon - this seems to be working. Many thanks.

amitchandak
Super User
Super User

@JonSwed , You can do bucket using segmentation or measure or column.

 

For measure refer my video and file attached after signature

https://youtu.be/CuczXPj0N-k

 

 

Or refer these

https://www.daxpatterns.com/dynamic-segmentation/
https://www.daxpatterns.com/static-segmentation/
https://www.poweredsolutions.co/2020/01/11/dax-vs-power-query-static-segmentation-in-power-bi-dax-po...
https://radacad.com/grouping-and-binning-step-towards-better-data-visualization

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan NL Carousel

Fabric Community Update - January 2025

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