Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Measure to count by selected criteria (first date and postal code)

Having the following table:   # Date UUID PostalCode 1 01-01-19 AAA 10001 2 01-01-19 AAA 10002 3 01-02-19 AAA 10003 4 01-05-19 BBB ...
  • v-joesh-msft's avatar
    v-joesh-msft
    6 years ago

    Hi Anonymous ,

    To get the result you want, you can try the following method:

    1. Create a calculated column as follows:

    test-PostalCode =
    VAR mind =
        MINX (
            FILTER ( 'Table', 'Table'[UUID] = EARLIER ( 'Table'[UUID] ) ),
            'Table'[Date]
        )
    RETURN
        CALCULATE (
            MIN ( 'Table'[PostalCode] ),
            FILTER ( ALLEXCEPT ( 'Table', 'Table'[UUID] ), 'Table'[Date] = mind )
        )

    2. Create a measure as follows:

    Measure = DISTINCTCOUNT('Table'[UUID])

    Results are as follows:

    Here is a demo, please try it:

    https://qiuyunus-my.sharepoint.com/:u:/g/personal/pbipro_qiuyunus_onmicrosoft_com/EVs6JVESPV9Ptkt7jXf4fDwB5E6hfCcB6FatmpL85tUuVA?e=jbK3a5 

    Best Regards,

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