Forum Discussion

H3nning's avatar
H3nning
Helper V
2 years ago
Solved

Distinct count depending on multiple lines

Hi,   i have a problem counting the number of customers that are customers for a certain period of time. Important: I dont want to count them once today, but for any given moment in time!   I hav...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi H3nning ,

    Based on your problems, here are my answers.

    First I create three tables as you mentioned.

    Then I write a  measure.

    Formatted Date = FORMAT('Date'[Date], "d.M.yyyy")

    Finally I write another measure and you will get what you want.

    MEASURE =
    VAR CurrentDate =
        SELECTEDVALUE ( 'Date'[Formatted Date] )
    RETURN
        CALCULATE (
            DISTINCTCOUNT ( Contract[Customer] ),
            FILTER (
                'Contract',
                Contract[Start] <= CurrentDate
                    && Contract[End] >= CurrentDate
            )
        )

     

     

     

    Best Regards

    Yilong Zhou

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.