Forum Discussion
Return text values from rows with same ID
Hi,
I want to do a product analysis where I list the frequency of each distinct product combination. My data looks like this:
I want to return values as in the ReturnValue column. After I get the ReturnValue I can do a simple DISTINCTCOUNT.
Is there a way I do this in a measure instead of creating a calculated column?
Much appreciated,
Lars
Hi Anonymous ,
We can create three columns then create a measure to meet your requirement.
1. Create a Contatenatex column, then create a column that ranks in the same Group, at last create a column to combine them.
Column = CONCATENATEX (FILTER('Table','Table'[Customer ID]=EARLIER('Table'[Customer ID])), 'Table'[Product Type], ", " )Rank in same ID = RANKX(FILTER('Table','Table'[Customer ID]=EARLIER('Table'[Customer ID])),'Table'[Product Type],,ASC,Dense)New Product Type = 'Table'[Column] &"-"& 'Table'[Rank in same ID]2. Then we can create a measure to distinct count the New Product Type column.
Distinctcount measure = DISTINCTCOUNT('Table'[New Product Type])If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?
Best regards,
Community Support Team _ zhenbw
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
BTW, pbix as attached.
6 Replies
- amitchandakSuper User
Anonymous , Why you need returnvalue to distinctcount you can do it on ID
You can use concatenatex , if needed
https://docs.microsoft.com/en-us/dax/concatenatex-function-dax
- AnonymousNot applicable
Thanks for your reply, amitchandak .How can I do it on ID directly in a measure? Can you please show me the formula?
Thanks!
- ChrisMendozaResident Rockstar
Anonymous
Expanding on what amitchandak has suggested...You can create a measure as:
CONCATENATEX Measure = CONCATENATEX ( Produkt, Produkt[Produkt], ", " )To deal with the Total Row you can do something like:
CONCATENATEX Measure = IF ( ISFILTERED ( Produkt[ID] ), CONCATENATEX ( Produkt, Produkt[Produkt], ", " ), DISTINCTCOUNT ( Produkt[ID] ) )