0

Say I have this data structure

Order Number Product Type
123 A
123 B
123 C
123 C
234 A
557 B
557 C

I would like to group by distinct values of product type per key so I get the following

Order Number Product Type Distinct Count
123 3
234 1
557 2

How do I do it in DAX? I currently have something like the below but it gives me 3 for each row since it doesn't count per Order Number

EVALUATE(

    SUMMARIZECOLUMNS(       
        [Order Number],
        "Product Type Distinct Count", DISCTINCTCOUNT([Product Type])       
    )
)

Thank you!!!!

Alon_T
  • 1,430
  • 4
  • 26
  • 47

1 Answers1

0

Try this calculated table instead:

# Distinct Product Types = 
SUMMARIZE(
    'Table',
    'Table'[Order Number],
    "Count", DISTINCTCOUNT('Table'[Product Type])
)

enter image description here

Peter
  • 10,959
  • 2
  • 30
  • 47
  • But what do I put as 'Table' if the metrics and fields in my database are TableA[Order Number] and TableB[Product Type]? Thanks – Alon_T Jan 24 '23 at 21:23
  • That's actually a new question for a new post with details about the relationship, but you can probably use SUMMARTIZECOLUMNS as a preparatory step. – Peter Jan 25 '23 at 06:17