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
mimingiang
Frequent Visitor

Calculate the first occurence based on selected period

Hi, 

I would like to calculate the first occurence of customer based on period selected. 

DateCustomerIDEventID
1/1/202311
1/1/202322
1/2/202333
1/2/202314
1/2/202325
1/3/202316
1/3/202317
1/3/20233

 

8

 

I want the result to look like this for period from 1/1/2023 - 1/2/2023 

 

 1/1/20231/2/2023Total
1101
2101
3111
Total213

 

I want the result to look like this for period from 1/2/2023 - 1/3/2023 

 

 1/2/20231/3/2023Total
1101
2101
3101
Total303
1 ACCEPTED SOLUTION

Just adjust the measure a little bit.

 

xifeng_L_0-1715760067133.png

 

Demo - Calculate the first occurence based on selected period.pbix

 

Did I answer your question? If yes, pls mark my post as a solution and appreciate your Kudos !

 

Thank you~

 

 

 

View solution in original post

3 REPLIES 3
xifeng_L
Super User
Super User

Hi @mimingiang ,

 

You can try below measure.

 

xifeng_L_1-1715674811919.png

 

xifeng_L_0-1715674797819.png

 

first occurence of custome = 
VAR SelectedPeriod = ALLSELECTED('Table'[Date])
RETURN
SUMX(
    SUMMARIZE('Table','Table'[CustomerID],'Table'[Date]),
    IF(CALCULATE(MIN('Table'[Date]),SelectedPeriod)='Table'[Date],1)
)

 

 

Did I answer your question? If yes, pls mark my post as a solution and appreciate your Kudos !

 

Thank you~

 

@xifeng_L Thank you so much for your reply. However, I need to make it work on Month level and it won't work for Month level if I have multiple dates in one month. Do you know how to make it work on month level? 

Date CustomerID 
01/01/2023 A 
01/01/2023 A 
02/01/2023 A 
02/01/2023 C 
01/02/2023 A 
02/02/2023 B 
02/02/2023 C 
02/02/2023 A 
01/03/2023 A 
01/03/2023 B 
01/03/2023 C 

 

I want the result to look like this for period from 1/1/2023 - 1/2/2023 

 

 01/202302/2023Total
A1 1
B 11
C1 1
Total213

Just adjust the measure a little bit.

 

xifeng_L_0-1715760067133.png

 

Demo - Calculate the first occurence based on selected period.pbix

 

Did I answer your question? If yes, pls mark my post as a solution and appreciate your Kudos !

 

Thank you~

 

 

 

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.