Forum Discussion
Count function issue in DAX
- 4 years ago
Hi there,
I think the immediate issue is that the measure needs to iterate over combinations of date & timestamp, rather than just timestamp.
You could use GENERATE or CROSSJOIN to create a table with all date/timestamp combinations (within the filter context), since we can't rely on 'Puffer Vergleich' to give us all the combinations.
For example:
<20 Count = COUNTROWS ( FILTER ( GENERATE ( VALUES ( 'Main Date Table'[Datum] ), VALUES ( '20 min timestamp'[20 Min timestamps] ) ), [Puffer Füllstand test] = "<20%" ) )Does this give the expected result?
For an alternative way of handling this type of calculation, have a look at Dynamic Segmentation on DAX Patterns.
Regards,
Owen
Hi again frittle
Thanks for that, that makes sense 🙂
In that case, I would change GENERATE to CROSSJOIN, and join the 3 columns together (Date, Time and BESCHREIBUNG).
I'm assuming you are applying filters on MAXTABLE[BESCHREIBUNG], as MAXTABLE is effectively set up as a dimension table. Otherwise change to the appropriate column reference:
<20 Count =
COUNTROWS (
FILTER (
CROSSJOIN (
VALUES ( MAXTABLE[BESCHREIBUNG] ),
VALUES ( 'Main Date Table'[Datum] ),
VALUES ( '20 min timestamp'[20 Min timestamps] )
),
[Puffer Füllstand test] = "<20%"
)
)
Does this work as expected?
Regards,
Owen