Forum Discussion
Find count of rows between start-end date in same table
- Anonymous1 year ago
Hi JGroothedde ,
Please refers to the following steps.
1. Create two dimension tables for the /datetime start/ field and the /datetime planned end/ fieldDimStartime = VALUES('Table'[datetime start]) DimEndtime = VALUES('Table'[datetime planned end])2. Creates a measure that calculates the count of rows.
Test = VAR _result = IF(SELECTEDVALUE('DimEndtime'[datetime planned end])>SELECTEDVALUE('DimStartime'[datetime start]), CALCULATE( COUNTROWS('Table'), KEEPFILTERS('Table'[datetime planned end]<=SELECTEDVALUE('DimEndtime'[datetime planned end])&&'Table'[datetime start]>=SELECTEDVALUE(DimStartime[datetime start])) ,'Table'[status]="Completed" ) ) RETURN IF(_result<>BLANK(),1,0)
3. Create slicers using fields from both dimension tables.
The result is shown below and hopefully meets your needs.
Please see the attached pbix for reference.
Best Regards,
Dengliang Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi JGroothedde ,
Please refers to the following steps.
1. Create two dimension tables for the /datetime start/ field and the /datetime planned end/ field
DimStartime = VALUES('Table'[datetime start])
DimEndtime = VALUES('Table'[datetime planned end])
2. Creates a measure that calculates the count of rows.
Test =
VAR _result =
IF(SELECTEDVALUE('DimEndtime'[datetime planned end])>SELECTEDVALUE('DimStartime'[datetime start]),
CALCULATE(
COUNTROWS('Table'),
KEEPFILTERS('Table'[datetime planned end]<=SELECTEDVALUE('DimEndtime'[datetime planned end])&&'Table'[datetime start]>=SELECTEDVALUE(DimStartime[datetime start]))
,'Table'[status]="Completed"
)
)
RETURN
IF(_result<>BLANK(),1,0)
3. Create slicers using fields from both dimension tables.
The result is shown below and hopefully meets your needs.
Please see the attached pbix for reference.
Best Regards,
Dengliang Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thank you Anonymous i have no clue why i didn't think of creating dimtables in the first place. Lifesaver, cheers!