Forum Discussion
Replacing a substring with selected value
- 3 years ago
Thank you for the clear explanation. Calculated columns do not communicate with the filter context. This has to be a measure
calcCustSubstitute =
SUBSTITUTE (
SELECTEDVALUE ( Phrases[phrase] ),
"[custName]",
SELECTEDVALUE ( customers[custName] )
)
tamerj1 ,
I apologize, but can't send a working file (network limitations...). Here are some screenshots. Hope they explain better than before:
Here is my entire database:
I defined a new column in table phrases:
calcYearSubstitute = SUBSTITUTE([phrase],"[year]","2022")
It works fine:
As you can see, in both phrases 2 and 3, the substring [year] was replaced by 2022.
Added a single-choice slicer based on customers[custName], and defined another column in phrases:
calcCustSubstitute = SUBSTITUTE([phrase],"[custName]",maxx('customers',[custName]))
No matter how I slice the customers, the substring [custName] in phrases 1 and 3 is always replaced by "Ringo" (alphabetic max of the customer list):
I want the newly defined column calcCustSubstitute to respond to the slicer on the page, so the substring [custName] would be replaced by "Paul" in this example, and any toher customer when slicing appropriately.
Thanks,
Aviram
Thank you for the clear explanation. Calculated columns do not communicate with the filter context. This has to be a measure
calcCustSubstitute =
SUBSTITUTE (
SELECTEDVALUE ( Phrases[phrase] ),
"[custName]",
SELECTEDVALUE ( customers[custName] )
)
- AviramWeiss3 years agoHelper I
Thank you very much, tamerj1 .
Now it works like a charm.