Forum Discussion
grggmrtn
5 years agoPost Patron
Distinct CountX?
I have the following DAX measure: CurrentBorger =
CALCULATE (
COUNTX (
FILTER (
'nexus2 Fact_VisiteretTid',
'nexus2 Fact_VisiteretTid'[Start] <= MAX ( Dato[Dato...
- 5 years ago
Ok I actually got it figured out, and it was a LOT easier than I thought it should have been 😄
First, I got rid of the relations between the tables.
Then it was just a matter of creating the following measure:
Measure = VAR StartDato = MIN ( Dato[Dato] ) VAR SlutDato = MAX ( Dato[Dato] ) RETURN CALCULATE ( DISTINCTCOUNT('nexus2 Fact_VisiteretTid'[CPRnrKort]), FILTER ( 'nexus2 Fact_VisiteretTid', ( 'nexus2 Fact_VisiteretTid'[Start] <= SlutDato && 'nexus2 Fact_VisiteretTid'[Stop] >= StartDato ) ) )Seriously, it solved all my problems, and the result validates. Go figure XD
PaulDBrown
5 years agoCommunity Champion
you might try wrapping the column in VALUES.
grggmrtn
5 years agoPost Patron
PaulDBrownwhat do you mean exactly?
- PaulDBrown5 years agoCommunity Champion
What I meant was:
CurrentBorger = CALCULATE ( COUNTX ( FILTER ( 'nexus2 Fact_VisiteretTid', 'nexus2 Fact_VisiteretTid'[Start] <= MAX ( Dato[Dato] ) && ( ISBLANK ( 'nexus2 Fact_VisiteretTid'[Stop] ) || 'nexus2 Fact_VisiteretTid'[Stop] >= MAX ( Dato[Dato] ) ) ), VALUES( 'nexus2 Fact_VisiteretTid'[CPRnrKort] ) ), CROSSFILTER ( 'nexus2 Fact_VisiteretTid'[Start], Dato[Dato], NONE ) )Actually, see if this works:
COUNTROWS( CALCULATETABLE( VALUES( 'nexus2 Fact_VisiteretTid'[CPRnrKort] ), FILTER ( 'nexus2 Fact_VisiteretTid', 'nexus2 Fact_VisiteretTid'[Start] <= MAX ( Dato[Dato] ) && ( ISBLANK ( 'nexus2 Fact_VisiteretTid'[Stop] ) || 'nexus2 Fact_VisiteretTid'[Stop] >= MAX ( Dato[Dato] ) ) ), CROSSFILTER ( 'nexus2 Fact_VisiteretTid'[Start], Dato[Dato], NONE ) )- grggmrtn5 years agoPost Patron
Eek - not quite - that took me from 1300+ to 4. I should be at about... 800-ish?
- PaulDBrown5 years agoCommunity Champion