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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
et123
New Member

Trouble with DAX calculating the number of distinct log ins

I have a table called 'View Data' that holds unique log ins to a report portal and the reports the user viewed; I want to count the views but not those that were in the same hour.  For example in the view below you can see this one user has 3 entries for the same time and date but this should only be counted once.

et123_0-1733309977033.png

Any ideas on how to write a measure that will do this?

Thanks

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @et123 ,
Thanks for divyed and rajendraongole1 reply.

Here is my sample data

vheqmsft_1-1733386018830.png

 


For the error in rajendraongole1  expression, you can change the code to

UniqueViewsPerHour = 
VAR UserHourGroups =
    ADDCOLUMNS(
        'View Data',
        "HourKey",
        CONCATENATE(
            FORMAT('View Data'[DateCreated], "YYYY-MM-DD HH"),
            'View Data'[SignIn]
        )
    )
RETURN
COUNTROWS(SUMMARIZE(UserHourGroups, [HourKey], 'View Data'[EmailAddress]))

Or you can create another measure

DistinctRowsMeasure = 
COUNTROWS(
    SUMMARIZE(
        'View Data', 
        'View Data'[DateCreated], 
        'View Data'[SignIn], 
        'View Data'[EmailAddress]
    )
)

Final output

vheqmsft_0-1733385999986.png

 

Best regards,
Albert He


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

4 REPLIES 4
Anonymous
Not applicable

Hi @et123 ,
Thanks for divyed and rajendraongole1 reply.

Here is my sample data

vheqmsft_1-1733386018830.png

 


For the error in rajendraongole1  expression, you can change the code to

UniqueViewsPerHour = 
VAR UserHourGroups =
    ADDCOLUMNS(
        'View Data',
        "HourKey",
        CONCATENATE(
            FORMAT('View Data'[DateCreated], "YYYY-MM-DD HH"),
            'View Data'[SignIn]
        )
    )
RETURN
COUNTROWS(SUMMARIZE(UserHourGroups, [HourKey], 'View Data'[EmailAddress]))

Or you can create another measure

DistinctRowsMeasure = 
COUNTROWS(
    SUMMARIZE(
        'View Data', 
        'View Data'[DateCreated], 
        'View Data'[SignIn], 
        'View Data'[EmailAddress]
    )
)

Final output

vheqmsft_0-1733385999986.png

 

Best regards,
Albert He


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

 

divyed
Super User
Super User

Hello @et123 ,

 

you can try below dax :

 

ViewsPerHour =
CALCULATE(
COUNTROWS(Events),
HOUR(Events[Datetime]) = HOUR(TODAY()) -- Replace TODAY() with a specific datetime if needed
)

 

I hope this helps.

Did I answer your query ? Please mark this as solution if this helps , Kudos are appreciated.

 

Cheers

LinkedIn : https://www.linkedin.com/in/neeraj-kumar-62246b26/
rajendraongole1
Super User
Super User

Hi @et123 - you can create a DAX measure that groups the records by hour and ensures duplicate logins within the same hour for the same user are not double-counted.

 

UniqueViewsPerHour =
VAR UserHourGroups =
ADDCOLUMNS(
'View Data',
"HourKey",
CONCATENATE(
FORMAT('View Data'[DateCreated], "YYYY-MM-DD HH"),
'View Data'[SignIn]
)
)
RETURN
DISTINCTCOUNT(UserHourGroups[HourKey])

 

Try this and let me know if any.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





I tried and I get this error 

et123_0-1733320288579.png

 

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors