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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
Anonymous
Not applicable

Calculate the number of occurrences before a certain date based on a condition

Hi,

I have a table like this:

 

User_emailLogin_DateFirst_Active_SessionLogins_to_First_Active_Session
emaila@test.com28/2/202228/2/20220
emaila@test.com18/3/202228/2/20220
emailb@test.com10/1/202215/2/20221
emailb@test.com15/2/202215/2/20221
emailb@test.com22/4/202215/2/20221
emailc@test.com1/5/202224/7/20223
emailc@test.com16/6/202224/7/20223
emailc@test.com28/6/202224/7/20223
emailc@test.com24/7/202224/7/20223

 

What I am trying to replicate is the number in the column called "Logins_to_First_Active_Session". Basically, I want to see how many logins occurred before the first active session per user email, excluding the first login (login 0).

 

How can I achieve this?

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

@Anonymous I believe you want something like:

Logins_to_First_Active_Session (column) =
  VAR __First_Active = [First_Active_Session]
  VAR __Email = [User_email]
RETURN
  COUNTROWS(FILTER('Table', [User_email] = __Email && [Login_Date] < __First_Active))


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

@Greg_Deckler thanks a lot it works like a charm!

Greg_Deckler
Community Champion
Community Champion

@Anonymous I believe you want something like:

Logins_to_First_Active_Session (column) =
  VAR __First_Active = [First_Active_Session]
  VAR __Email = [User_email]
RETURN
  COUNTROWS(FILTER('Table', [User_email] = __Email && [Login_Date] < __First_Active))


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 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.