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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
beaoliv123-_
Helper I
Helper I

Dynamic Unique Visitors

Hi, 

I would like to calculate the number of unique visitors based on the date range that the user decides to see. For example, if I select a date between last week and today, I would like to see the number of unique visitors of that period; if I select only yestarday and today, I would like to see the new visitors from yesterday until now.

Thank you.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @beaoliv123-_ ,

 

You may firstly refer to @Whitewater100 's pbix.

 

And I have created a data sample to test:

Eyelyn9_0-1648106107960.png

And use CALENDAR() to create a Date table for slicer:

For Slicer = CALENDAR(MIN('Table'[Date]),MAX('Table'[Date]))

Then create a measure:

Count of Unique Users = CALCULATE(DISTINCTCOUNT('Table'[User ID]),FILTER('Table',[Date]>=MIN('For Slicer'[Date]) && [Date]<=MAX('For Slicer'[Date])))

Output:

Eyelyn9_1-1648108078794.png


Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

9 REPLIES 9
Whitewater100
Solution Sage
Solution Sage

Hi:

What didn't work on my previous solution? I understood you wanted to compare unique visitors..

Whitewater100_0-1648132407088.png

 

beaoliv123-_
Helper I
Helper I

Thank you all for your answers, you realy helped me solve the question.

Anonymous
Not applicable

Hi @beaoliv123-_ ,

 

You may firstly refer to @Whitewater100 's pbix.

 

And I have created a data sample to test:

Eyelyn9_0-1648106107960.png

And use CALENDAR() to create a Date table for slicer:

For Slicer = CALENDAR(MIN('Table'[Date]),MAX('Table'[Date]))

Then create a measure:

Count of Unique Users = CALCULATE(DISTINCTCOUNT('Table'[User ID]),FILTER('Table',[Date]>=MIN('For Slicer'[Date]) && [Date]<=MAX('For Slicer'[Date])))

Output:

Eyelyn9_1-1648108078794.png


Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Whitewater100
Solution Sage
Solution Sage

Hi:

Do you have a FacTable with visitor ID, date of visit and a Visitor lookup dimension table , along with a date table marked as such? That would be ideal for Power BI to answer your question.

 

What would be the period of increment for evaluation? e.g. Measuring back 28 days in daily increments or weekly increments? I'll paste a couple of images that help show how this type of analysis is best set up. You could have at least a Date and Customer dimension table (you may already but not evident from question)

 

Whitewater100_0-1647622231299.png

This input helps the measure figure what you consider as lost or new and returning.

Whitewater100_1-1647622363503.png

If you don't have all this, below is Jeffery Wang's (inventor of DAX) measure for new customers(vistors):

New Cust = vcustomersthis period = VALUES(Sales[CustKey])
var vfirstdatethisperiod = MIN(Sales[orderdate])
var vcustomersbefore = CALCULATETABLE(VALUES(Sales[custkey], 
                                       FILTER(ALL(Sales[orderdate]), [orderdate] < vfirstdatethisperiod, ALL(DATES))
return

COUNTROWS(EXCEPT(vcustomersthisperiod, vcustomersbefore))

 

With this measure if you have day in the visual column it will be based on day. If you have week, then it's week based and so on.

 

Hi,

thanks for your help. I have a table with the customers ID and a Date table.

My goal is to change the way it calculates the unique visitors, based on the date filter. For example, if I select a week on the slicer, the calculation for the unique visitors considers 1 week, and the same for other selections.

Hi:

Do you think you could make up some sample data for the tables? The way your model is set up and relationships determines the calculation. If it looks like this (below) I could probably try to create mock data.

 

Whitewater100_0-1647877763229.png

 

Table1

Date
User ID (each time a user comes in, the user ID appears)

 

 

Table2
Year
Quarter
Month
Day

 

 

My goal is to calculate the distinct user ID, but this measure must be dynamic with the date.

Ex.:
If I select a date between last week and today, then it will count each user ID once between these two dates. And depending on the date selection, I want the distinct count to change.

Hi:

I understand. I will make up some data to experiment with but only can look at it a bit later today. Thanks!

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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