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
ssspk
Helper I
Helper I

How to find the Unique users per day from a single Table with columns available?

Hello Team,

 

I have to find the DAX Query or Measure for unique users per day based on the below python code,

events_per_user_per_day = all_events.groupby([pd.Grouper(key='servertime', freq='D', label='left'), 'user'])[['appId']].count()
f = events_per_user_per_day.groupby(level="servertime").size().plot()

 

My SQL query is like below,

SELECT   DATE(servertime) AS Day,  user AS User,  COUNT(appid) AS EventsPerUserPerDay
FROM  traces
INNER JOIN traces on data.type = type.id
WHERE typename in ('bookmark','app')
AND appid >  0
GROUP BY  DATE(servertime), user
ORDER BY 1 DESC
 
My DAX Measure,
 
_UniqueClicksPerDay =
VAR ClicksPerUserAndAppPerDay =
    SUMMARIZE(
        'data',
        'data'[servertime],
        'data'[user],
        'data'[appid],
        "ClicksCount", COUNTROWS('data')
    )
RETURN
SUMMARIZE(
    ADDCOLUMNS(
        GROUPBY(
            ClicksPerUserAndAppPerDay,
            'data'[servertime],
            'data'[appid],
            "UniqueUsers",
            DISTINCTCOUNT('data'[user])
        ),
        "UniqueClicks", [ClicksCount] / [UniqueUsers]
    ),
    'data'[servertime],
    'data'[appid],
    "UniqueClicks", [UniqueClicks]
)
 
error_1.png
 
 
 
 
How to find the 'Unique user per day' based on the below details,
TableName:data
Column1:servertime
Column2:user
Column3:appid
There are n number of application available and each has different appid.each click creates one entry in db.
User who ever clicks the application it creates an entry in database as ex: user: 45296 appid: 460 servertime: datatime
How to form a DAX or Measure ot Table?
 
Thanks and Regards,
Siva
1 REPLY 1
v-jialongy-msft
Community Support
Community Support

Hi @ssspk 

 

Please try the following methods:

1: DAX Measure for Unique Users Per Day

If you want a measure that you can use in visuals to dynamically calculate unique users per day based on the current filter context, use the following DAX measure:

 

Unique Users Per Day =
COUNTROWS(
SUMMARIZE(
'data',
'data'[servertime],
'data'[user]
)
)

This measure counts the unique combinations of `servertime` and `user`, effectively giving you the number of unique users per day. It's worth noting that the `servertime` column should be a date or datetime type. If `servertime` includes times, you might need to convert it to a date-only format within the measure, like so:

Unique Users Per Day =
COUNTROWS(
SUMMARIZE(
'data',
DATEVALUE('data'[servertime]),
'data'[user]
)
)



2: Calculated Table for Unique Users Per Day

If your goal is to create a calculated table that lists each day with the count of unique users for that day, you can use the following DAX expression:

Unique Users Per Day Table =
SUMMARIZE(
'data',
DATEVALUE('data'[servertime]),
"UniqueUsers", DISTINCTCOUNT('data'[user])
)

This calculated table will have two columns: one for the day and one for the count of unique users for each day ('UniqueUsers').

 

 

 

 

 

Best Regards,

Jayleny

 

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

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.