The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. 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.
User | Count |
---|---|
26 | |
10 | |
8 | |
6 | |
5 |
User | Count |
---|---|
33 | |
13 | |
11 | |
9 | |
8 |