Forum Discussion
Concatenate values based on new and old value
Hi there,
I could need you help.
I got a table that is looking like this:
| IssueId | AUTHOR | CREATED | FIELD | OLDVALUE | NEWVALUE | pkey |
| 3370181 | [email protected] | 2023-02-09 14:30:47.000 | Fix Version | NULL | VERSION-17.0.51A | MAIN-23443 |
| 3370181 | [email protected] | 2023-02-10 10:23:07.000 | Fix Version | NULL | VERSION-17.0.52 | MAIN-23443 |
| 3370181 | [email protected] | 2023-02-10 10:23:07.000 | Fix Version | VERSION-17.0.51A | NULL | MAIN-23443 |
| 3370181 | [email protected] | 2023-02-10 10:23:07.000 | Fix Version | NULL | VERSION-17.2.29 | MAIN-23443 |
| 3370181 | [email protected] | 2023-02-10 10:23:07.000 | TimeEstimate | 300 | 400 | MAIN-23443 |
| 3370181 | [email protected] | 2023-02-10 10:25:31.000 | Fix Version | VERSION-17.0.52 | NULL | MAIN-23443 |
| 3370181 | [email protected] | 2023-02-10 10:25:31.000 | Fix Version | NULL | VERSION-17.0.53 | MAIN-23443 |
I want to add a new column thats checking if a Version is assigned to a NEWVALUE. Then it should use this version. N Version can be assiged to new values without beeing removed. Removed means Field =Fixed Version and newvalue for this Version is NULL.
To be more clear plz take a look at my last column here. It should look like this in the end and it should be grouped by pkey as the pkey will change.
| IssueId | AUTHOR | CREATED | FIELD | OLDVALUE | NEWVALUE | pkey | Correct |
| 3370181 | [email protected] | 2023-02-09 14:30:47.000 | Fix Version | NULL | VERSION-17.0.51A | MAIN-23443 | VERSION-17.0.51A |
| 3370181 | [email protected] | 2023-02-10 10:23:07.000 | Fix Version | NULL | VERSION-17.0.52 | MAIN-23443 | VERSION-17.0.51A,VERSION-17.0.52 |
| 3370181 | [email protected] | 2023-02-10 10:23:07.000 | Fix Version | VERSION-17.0.51A | NULL | MAIN-23443 | VERSION-17.0.52 |
| 3370181 | [email protected] | 2023-02-10 10:23:07.000 | Fix Version | NULL | VERSION-17.2.29 | MAIN-23443 | VERSION-17.0.52,VERSION-17.2.29 |
| 3370181 | [email protected] | 2023-02-10 10:23:07.000 | TimeEstimate | 300 | 400 | MAIN-23443 | VERSION-17.0.52,VERSION-17.2.29 |
| 3370181 | [email protected] | 2023-02-10 10:25:31.000 | Fix Version | VERSION-17.0.52 | NULL | MAIN-23443 | VERSION-17.2.29 |
| 3370181 | [email protected] | 2023-02-10 10:25:31.000 | Fix Version | NULL | VERSION-17.0.53 | MAIN-23443 | VERSION-17.2.29,VERSION-17.0.53 |
I am thinking of something like an indexed column grouped by pkey that is populated with the values from NewValue and Oldvalue if the Field = Fix Version. Do you know how to solve this? Thx in advance.
Thorsten
Hi AsaThor - i have created a calculated column as below:
Please check
you can replace table name as per your model.
Correct =VAR CurrentPKey = 'concc'[pkey]VAR CurrentCreated = 'concc'[CREATED]VAR AllRows =FILTER('concc','concc'[pkey] = CurrentPKey &&'concc'[CREATED] <= CurrentCreated)VAR Additions =DISTINCT(SELECTCOLUMNS(FILTER(AllRows, 'concc'[FIELD] = "Fix Version" && NOT(ISBLANK('concc'[NEWVALUE]))),"Version", 'concc'[NEWVALUE]))VAR Removals =DISTINCT(SELECTCOLUMNS(FILTER(AllRows, 'concc'[FIELD] = "Fix Version" && NOT(ISBLANK('concc'[OLDVALUE]))),"Version", 'concc'[OLDVALUE]))VAR ActiveVersions =EXCEPT(Additions, Removals)RETURNCONCATENATEX(ActiveVersions, [Version], ", ")
3 Replies
- rajendraongole1
Super User
Hi AsaThor - i have created a calculated column as below:
Please check
you can replace table name as per your model.
Correct =VAR CurrentPKey = 'concc'[pkey]VAR CurrentCreated = 'concc'[CREATED]VAR AllRows =FILTER('concc','concc'[pkey] = CurrentPKey &&'concc'[CREATED] <= CurrentCreated)VAR Additions =DISTINCT(SELECTCOLUMNS(FILTER(AllRows, 'concc'[FIELD] = "Fix Version" && NOT(ISBLANK('concc'[NEWVALUE]))),"Version", 'concc'[NEWVALUE]))VAR Removals =DISTINCT(SELECTCOLUMNS(FILTER(AllRows, 'concc'[FIELD] = "Fix Version" && NOT(ISBLANK('concc'[OLDVALUE]))),"Version", 'concc'[OLDVALUE]))VAR ActiveVersions =EXCEPT(Additions, Removals)RETURNCONCATENATEX(ActiveVersions, [Version], ", ") - AsaThorNew Member
I will have a look but what I see on your output seems not to get the correct values:
- rajendraongole1
Super User
Hi AsaThor - i have create a explicit measure.
Correct2 =VAR CurrentPKey = 'concc'[pkey]VAR CurrentCreated = 'concc'[CREATED]VAR AllRows =FILTER('concc','concc'[pkey] = CurrentPKey && 'concc'[CREATED] <= CurrentCreated)VAR Additions =DISTINCT(SELECTCOLUMNS(FILTER(AllRows, 'concc'[FIELD] = "Fix Version" && NOT(ISBLANK('concc'[NEWVALUE]))),"Version", 'concc'[NEWVALUE]))VAR Removals =DISTINCT(SELECTCOLUMNS(FILTER(AllRows, 'concc'[FIELD] = "Fix Version" && NOT(ISBLANK('concc'[OLDVALUE]))),"Version", 'concc'[OLDVALUE]))VAR ActiveVersions =EXCEPT(Additions, Removals)RETURNCONCATENATEX(ActiveVersions, [Version], ", ")Please check the attached code.