Forum Discussion
ek2112
Advocate II
8 years agoGROUP BY calculated column
Hello, I have the data in the following format - is there a way to extract all salesperson names and write them into a new calculated column for each invoice number? Thank you.
- 8 years ago
May be
Calculated_Column = VAR InvoiceNo = [Invoice No] RETURN CONCATENATEX ( FILTER ( Sales, Sales[Invoice No] = InvoiceNo ), Sales[Salesperson], ", " ) - 8 years ago
Zubair_Muhammad thanks for looking into this, this works, but coming up with duplicates. Is there a way to suppress duplicates?
Anonymous
8 years agoNot applicable
Ok, so you are trying to create the last column, its not part of your initial dataset.
Here is some dax code that should be close to what you are looking for. You might need to add more variables if you have more constraints on what to be placed on which lines a sales persons name gets placed on.
Calculated Column = var InvoiceNo = [Invoice No]
RETURN
CONCATENATEX(
CALCULATE(
DISTINCT('YourTable'[SalesPerson]),
ALL('YourTable'),
'YourTable'[Invoice No] = InvoiceNo
),
[SalesPerson],
", "
)ek2112
Advocate II
8 years agoAnonymous Thanks, I tried with the measure, but I get an error "table of multiple values was supplied where a single value was expected". Here is the sample pbix.
- Zubair_Muhammad8 years ago
Community Champion
May be
Calculated_Column = VAR InvoiceNo = [Invoice No] RETURN CONCATENATEX ( FILTER ( Sales, Sales[Invoice No] = InvoiceNo ), Sales[Salesperson], ", " )- ek21128 years ago
Advocate II
Zubair_Muhammad thanks for looking into this, this works, but coming up with duplicates. Is there a way to suppress duplicates?