cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper II
Helper II

Retrieve Last Occurrence of each record per week

Hi, 

 

I would like to retrieve in a new column in DAX, called Last Occurrence, 1 for the last occurence of each record, per week and 0 for the others. 

 

Below is what I want to replicate. 

 

Many thanks in advance,

Melisa

recorddateweeknoLast Occurrence
10014822/11/202070
10014822/13/202070
10014822/14/202070
10014822/15/202071
10014822/17/202080
10014822/18/202080
10014822/19/202081
10014822/24/202090
10014822/25/202090
10014822/26/202091
12543332/11/202070
12543332/13/202070
12543332/14/202071
12543332/17/202080
12543332/18/202081
12543332/24/202090
12543332/25/202090
12543332/26/202090
12543332/27/202091

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User IV
Super User IV

Re: Retrieve Last Occurrence of each record per week

Try a new column like

 

 

Last Occurrence = if(table[date] - maxx(filter(table,table[record]=earlier(table[record]) && table[week]=earlier(table[week])),table[date]), 1, 0)

 

 



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
My Recent Blog -Week is not so Weak Connect on Linkedin

Proud to be a Super User!

View solution in original post

4 REPLIES 4
Highlighted
Super User IV
Super User IV

Re: Retrieve Last Occurrence of each record per week

Try a new column like

 

 

Last Occurrence = if(table[date] - maxx(filter(table,table[record]=earlier(table[record]) && table[week]=earlier(table[week])),table[date]), 1, 0)

 

 



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
My Recent Blog -Week is not so Weak Connect on Linkedin

Proud to be a Super User!

View solution in original post

Highlighted
Helper II
Helper II

Re: Retrieve Last Occurrence of each record per week

Hi @amitchandak 

Unfortunately the datemaxx function you mentioned in the formula is not recognized by Power BI. Can we use smtg else instead?

Thank you,

Melisa

 

Highlighted
Helper II
Helper II

Re: Retrieve Last Occurrence of each record per week

@amitchandak I have used the MAXX function and it's working. Thank you very much!

 

Highlighted
Super User IV
Super User IV

Re: Retrieve Last Occurrence of each record per week

Thanks for pointing out. I corrected the original post. Kudos to You !!

 



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
My Recent Blog -Week is not so Weak Connect on Linkedin

Proud to be a Super User!

Helpful resources

Announcements
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Upcoming Events

Upcoming Events

Wondering what events you could join or have an event to promote yourself? Check out our Upcoming Events.

Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

We are thrilled to announce we will begin running a monthly webinar series named Power BI Dev Camp.

Top Solution Authors
Top Kudoed Authors