The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
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 4 | list 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 be2 | list only the added new IDs should be b,e |
Is that achievable with DAX ?
Solved! Go to Solution.
@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
@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
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.
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the August 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
21 | |
18 | |
15 | |
14 | |
14 |
User | Count |
---|---|
37 | |
33 | |
22 | |
18 | |
17 |