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 August 31st. Request your voucher.

Reply
rco123456
Microsoft Employee
Microsoft Employee

Count occurrences of user

hi i want to create two mesures, 

one that calculate new user and one that calculate  return user

dateuseridactivityid
1/1/202011
1/1/202022
1/1/202013
2/1/20014
2/1/202015
3/1/202016

 

user number 1 will be return user , becuse he will apper in the recoreds in a few diffrent date.

user 2 will be a new user, becuse he apper only on the first day of the records 

 

 

 

 

 

 

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Picture1.png

 

New User Measure : =
VAR _firstdayoftherecords =
CALCULATE ( MIN ( Data[date] ), REMOVEFILTERS ( Data ) )
VAR _newtable =
ADDCOLUMNS (
SUMMARIZE ( Data, Users[userid] ),
"@firstdaycount", CALCULATE ( COUNTROWS ( Data ), Dates[date] = _firstdayoftherecords ),
"@otherthanfirstdaycount", CALCULATE ( COUNTROWS ( Data ), Dates[date] <> _firstdayoftherecords )
)
VAR _filtertableforcount =
FILTER ( _newtable, [@firstdaycount] > 0 && [@otherthanfirstdaycount] = 0 )
RETURN
COUNTROWS ( _filtertableforcount )
 
 
Return User Measure : =
VAR _firstdayoftherecords =
CALCULATE ( MIN ( Data[date] ), REMOVEFILTERS ( Data ) )
VAR _newtable =
ADDCOLUMNS (
SUMMARIZE ( Data, Users[userid] ),
"@firstdaycount", CALCULATE ( COUNTROWS ( Data ), Dates[date] = _firstdayoftherecords ),
"@otherthanfirstdaycount", CALCULATE ( COUNTROWS ( Data ), Dates[date] <> _firstdayoftherecords )
)
VAR _filtertableforcount =
FILTER ( _newtable, [@firstdaycount] > 0 && [@otherthanfirstdaycount] > 0 )
RETURN
COUNTROWS ( _filtertableforcount )
 
 
 
 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

1 REPLY 1
Jihwan_Kim
Super User
Super User

Picture1.png

 

New User Measure : =
VAR _firstdayoftherecords =
CALCULATE ( MIN ( Data[date] ), REMOVEFILTERS ( Data ) )
VAR _newtable =
ADDCOLUMNS (
SUMMARIZE ( Data, Users[userid] ),
"@firstdaycount", CALCULATE ( COUNTROWS ( Data ), Dates[date] = _firstdayoftherecords ),
"@otherthanfirstdaycount", CALCULATE ( COUNTROWS ( Data ), Dates[date] <> _firstdayoftherecords )
)
VAR _filtertableforcount =
FILTER ( _newtable, [@firstdaycount] > 0 && [@otherthanfirstdaycount] = 0 )
RETURN
COUNTROWS ( _filtertableforcount )
 
 
Return User Measure : =
VAR _firstdayoftherecords =
CALCULATE ( MIN ( Data[date] ), REMOVEFILTERS ( Data ) )
VAR _newtable =
ADDCOLUMNS (
SUMMARIZE ( Data, Users[userid] ),
"@firstdaycount", CALCULATE ( COUNTROWS ( Data ), Dates[date] = _firstdayoftherecords ),
"@otherthanfirstdaycount", CALCULATE ( COUNTROWS ( Data ), Dates[date] <> _firstdayoftherecords )
)
VAR _filtertableforcount =
FILTER ( _newtable, [@firstdaycount] > 0 && [@otherthanfirstdaycount] > 0 )
RETURN
COUNTROWS ( _filtertableforcount )
 
 
 
 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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