Forum Discussion

grggmrtn's avatar
grggmrtn
Post Patron
5 years ago
Solved

Distinct CountX?

I have the following DAX measure: CurrentBorger = CALCULATE ( COUNTX ( FILTER ( 'nexus2 Fact_VisiteretTid', 'nexus2 Fact_VisiteretTid'[Start] <= MAX ( Dato[Dato...
  • grggmrtn's avatar
    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