Forum Discussion
Concatenate Columns If Same ID
- 9 years ago
Since your data set did not have any items that were in only 1 year, I created a similar set which you can find in this linked pbix file.
Multiple table model is required to get the results above.
Here are the measures:
Count If Item Sold in Only 1 Year =
COUNTROWS ( FILTER ( 'Items', [Item Years in Catalog] = 1 ) )Item Catalog Years =
IF (
NOT ( ISBLANK ( SELECTEDVALUE ( Items[Item ID] ) ) ),
CONCATENATEX ( RELATEDTABLE ( Data ), Data[Catalog Year], ", " )
)Item Total Years in Catalog =
CALCULATE (
COUNTROWS ( VALUES ( 'Years'[Year] ) ),
CROSSFILTER ( Data[Catalog Year], Years[Year], BOTH )
)Tom
- Anonymous9 years ago
Hi khappersett,
I think you need to filter the records which has the same id, then use this as the source of concatenate function.
All Year = CONCATENATEX(FILTER(ALL('sample'),[Item ID]=EARLIER('sample'[Item ID])),[Catalog Year],",")Regards,
Xiaoxin Sheng
Hi khappersett,
I think you need to filter the records which has the same id, then use this as the source of concatenate function.
All Year = CONCATENATEX(FILTER(ALL('sample'),[Item ID]=EARLIER('sample'[Item ID])),[Catalog Year],",")
Regards,
Xiaoxin Sheng
- P3Tom9 years ago
Helper I
Although this topic is titled, "Concatenate Columns If Same ID", later in the original request it says:
"Ultimately, I am trying to find a way to count the items that are in a catalog for one year, but not another."
Restated, concatenation was a means used to count the items that are in a catalog only for one year, but not another.
A complete solution will also give an answer to the ultimate end (what is the count of catalog items that were listed for only one year).
Tom
- filipe1978 years agoFrequent Visitor
Hello Anonymous
What if additionally you have for the same Item ID duplicate Catalog Year? How could you consider in your formula only the unique values? I mean, if item ID "A" have in column "Catalog Year" the values 2012,2012 and 2014 i just want to consider in "All year" this result: 2012,2014.
Thanks,
filipe197
- Ashish_Mathur8 years ago
Super User
- filipe1978 years agoFrequent Visitor
- ewkcoder3 years agoFrequent Visitor
This worked for my use case. I extended this with an additional condition to exclude a field value from being included in the concatenation.
All Year = CONCATENATEX(FILTER(ALL('sample'),[Item ID]=EARLIER('sample'[Item ID]) && [Item ID]<>"Not Supplied"),[Catalog Year],",")