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] )
)
Hi AviramWeiss
Make sure you are fitering the Customer Name from the customer table. Also double check interactions.
Thank you, tamerj1 .
I'm using the same field, in the same table, to filter.
As for interactions - as far as I understand, there should be no relationship between the 2 tables, as the text-parts are not specific to a customer. I double checked, and there are no relationships (actually, the text-part table is stand-alone, and is not connected to any other table in the project).
- tamerj13 years agoCommunity Champion
Interactions are between slicers and visuals snd between different visuals. However, I don't think this is the problem. Can you please share some screenshots to clarify the picture?
- AviramWeiss3 years agoHelper I
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
- tamerj13 years agoCommunity Champion
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] )
)