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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
barakm
Frequent Visitor

count and list only the new added values from the previous week

I’m trying to solve the following:  

I have one excel table contains columns of values(ID) and startTime + endTime for every week

I would like to count and also list only the new added values from the previous week

For example: first 7 values from first week, then 9 values fron second week , then 10 values

ID

startTime

endTime

   

a

02-Jul-24

09-Jul-24

   

b

02-Jul-24

09-Jul-24

   

c

02-Jul-24

09-Jul-24

   

d

02-Jul-24

09-Jul-24

   

e

02-Jul-24

09-Jul-24

   

f

02-Jul-24

09-Jul-24

   

g

02-Jul-24

09-Jul-24

   

a

09-Jul-24

16-Jul-24

   

c

09-Jul-24

16-Jul-24

   

d

09-Jul-24

16-Jul-24

   

f

09-Jul-24

16-Jul-24

   

g

09-Jul-24

16-Jul-24

 

 

 

h

09-Jul-24

16-Jul-24

 

 

 

i

09-Jul-24

16-Jul-24

   

j

09-Jul-24

16-Jul-24

   

k

09-Jul-24

16-Jul-24

 count of new IDs from previous week should be 4list only the added new IDs should be h,I,j,k

a

16-Jul-24

23-Jul-24

   

b

16-Jul-24

23-Jul-24

   

c

16-Jul-24

23-Jul-24

   

d

16-Jul-24

23-Jul-24

   

e

16-Jul-24

23-Jul-24

   

g

16-Jul-24

23-Jul-24

 

 

 

h

16-Jul-24

23-Jul-24

   

i

16-Jul-24

23-Jul-24

   

j

16-Jul-24

23-Jul-24

   

k

16-Jul-24

23-Jul-24

 count of new IDs from previous week should be2list only the added new IDs should be  b,e

 

Is that achievable with DAX ?  

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@barakm Try these. PBIX is attached below signature.

Count New Measure = 
    VAR __CurrentWeek = MAX('Table'[startTime])
    VAR __Current = DISTINCT( 'Table'[ID] )
    VAR __Previous = DISTINCT( SELECTCOLUMNS( FILTER( ALL('Table'), [startTime] = __CurrentWeek - 7 ), "ID", [ID] ) )
    VAR __New = EXCEPT( __Current, __Previous)
    VAR __Result = COUNTROWS( __New )
RETURN
    __Result


List New Measure = 
    VAR __CurrentWeek = MAX('Table'[startTime])
    VAR __Current = DISTINCT( 'Table'[ID] )
    VAR __Previous = DISTINCT( SELECTCOLUMNS( FILTER( ALL('Table'), [startTime] = __CurrentWeek - 7 ), "ID", [ID] ) )
    VAR __New = EXCEPT( __Current, __Previous)
    VAR __Result = CONCATENATEX( __New, [ID], "," )
RETURN
    __Result


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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Greg_Deckler
Super User
Super User

@barakm Try these. PBIX is attached below signature.

Count New Measure = 
    VAR __CurrentWeek = MAX('Table'[startTime])
    VAR __Current = DISTINCT( 'Table'[ID] )
    VAR __Previous = DISTINCT( SELECTCOLUMNS( FILTER( ALL('Table'), [startTime] = __CurrentWeek - 7 ), "ID", [ID] ) )
    VAR __New = EXCEPT( __Current, __Previous)
    VAR __Result = COUNTROWS( __New )
RETURN
    __Result


List New Measure = 
    VAR __CurrentWeek = MAX('Table'[startTime])
    VAR __Current = DISTINCT( 'Table'[ID] )
    VAR __Previous = DISTINCT( SELECTCOLUMNS( FILTER( ALL('Table'), [startTime] = __CurrentWeek - 7 ), "ID", [ID] ) )
    VAR __New = EXCEPT( __Current, __Previous)
    VAR __Result = CONCATENATEX( __New, [ID], "," )
RETURN
    __Result


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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Thank you Greg, I manage to copy the DAX code and numbers seems to be OK 😀.  as for the list of the value I I would like to see it in a table where I could choose with a slicer which week to show... for some reason I was not able to download your PBIX, maybe you can try send it my email ? barak.m7@gmail.com ... but overall I'm very happy with what you've sent till now, amazing ! of course I'll be happy to mark your post as a solution.   

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

AugPowerBI_Carousel

Power BI Monthly Update - August 2024

Check out the August 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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