Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
lsealy
Frequent Visitor

Need to incorporate a text search slicer into custom columns of a report

Hello. Is it possible to incorporate a text search slicer value in a calculated column formula? If the answer is no, I don't know how to achieve an objective. I have a text search slicer that filters rows in a visual, based on a table column 'FromTo' that concatenates columns 'From' and 'To'. 

 

I'm hoping to create a calculated column 'BarrierFeetFromTo', where if column 'From' includes the text in the text search slicer, a value is returned based on another column 'BarrierFeet' and the value would be 'BarrierFeet' *-1; if column 'To' includes the text search slicer text, the BarrierFeet value would be returned. 

 
Can someone help me with this? Thank you!
 
link to .pbix file: FASearch - Power BI
 

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi,@lsealy I am glad to help you.
Hello,@Ritaf1983 ,thanks for your concern about this issue.

Your answer is excellent! And I would like to share some additional solutions below

Hello, according to your description, you want to implement the ability to create a new calculated column in power bi by artificially selecting the text value on the slicer and determining whether the [From] and [To] in the table contain the value from the slicer or not.

I was unable to open the link you provided, so I created simple test data, here is my test

Unfortunately, your idea is challenging because it involves the definition of a calculated column.
The creation of a calculated column is calculated when the values are loaded and refreshed, so it is static and there is no way to implement dynamic slicing

vjtianmsft_0-1721624836480.png

For example, it is not possible to use the selectedvalue function, the return value is null.
What you need is actually more feasible in the form of a measure, as you said, but what you need is to create a relationship using the target column.
So in order to realize your need, you need to manipulate the original data.
Here are my suggestions, if your problem is not yet solved, you can refer to them

1. Pre-process the numbers: Create a column in the data source containing the text of possible searches, and then use this column directly in Power BI to use the processed data.
2. Using Power Query: If you don't want to modify the original data source, you can try the above operation in Power Query.
like this.
You will need to add a column to the model that contains the slicer filter fields. Let's say that my test data uses slicer_value for field filtering.
The idea is that you can add the slicer column to the model, and then form a new column (which doesn't actually have a real value) by stitching together each of the values in the To and From columns in a string splice.
A new column (not actually created, but by way of a var variable), determine if the value in the slicer is in the From or To column, and if it is, then categorize it and return a different [BarrierFeet] column The processed value (either the original value or the corresponding negative value)

 

 

C_FormAllValues = 
  VAR _Form_allvalue=CONCATENATEX(
    VALUES('Test_table'[From]),
    [From],
    ","
  )
  VAR _To_allvalue=CONCATENATEX(
    VALUES('Test_table'[To]),
    [To],
    ","
  )
 RETURN
 IF(CONTAINSSTRING(_Form_allvalue,[slicer_value]),[BarrierFeet]*-1,
        IF(CONTAINSSTRING(_To_allvalue,'Test_table'[slicer_value]),[BarrierFeet],BLANK())
 )

 

 

vjtianmsft_1-1721624891621.png

 

vjtianmsft_3-1721624937675.png

 

This method can fulfill your needs to some extent, but you need to make sure that the data source and slicer values are correct and consistent. If you have a large amount of data, it is recommended that you test the performance in real applications to ensure that it does not affect the responsiveness of the reports, so you can try it out and use it as an alternative.
If you think my suggestion is a good one to try, it would be a good idea to pre-process the data in the data source to minimize the need to re-create calculated columns when creating a new report.

As a matter of fact, after communicating your requirements to the team, I came to the conclusion that it is possible to create a MEASURE but not a physical column (calculated column) because the slicer itself is a VISUAL and its values are dependent on other columns, but the reverse does not hold true, you cannot create a calculated column with fixed operations by using the dynamic values of the slicer, which is illogical!
You need to make sure that the data requirements are met in the physical columns before you can create a virtual table or perform string splice matching to fulfill your needs.
I wish you the best of luck in finding a suitable solution.

 

I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.

Best Regards,

Carson Jian,

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi,@lsealy I am glad to help you.
Hello,@Ritaf1983 ,thanks for your concern about this issue.

Your answer is excellent! And I would like to share some additional solutions below

Hello, according to your description, you want to implement the ability to create a new calculated column in power bi by artificially selecting the text value on the slicer and determining whether the [From] and [To] in the table contain the value from the slicer or not.

I was unable to open the link you provided, so I created simple test data, here is my test

Unfortunately, your idea is challenging because it involves the definition of a calculated column.
The creation of a calculated column is calculated when the values are loaded and refreshed, so it is static and there is no way to implement dynamic slicing

vjtianmsft_0-1721624836480.png

For example, it is not possible to use the selectedvalue function, the return value is null.
What you need is actually more feasible in the form of a measure, as you said, but what you need is to create a relationship using the target column.
So in order to realize your need, you need to manipulate the original data.
Here are my suggestions, if your problem is not yet solved, you can refer to them

1. Pre-process the numbers: Create a column in the data source containing the text of possible searches, and then use this column directly in Power BI to use the processed data.
2. Using Power Query: If you don't want to modify the original data source, you can try the above operation in Power Query.
like this.
You will need to add a column to the model that contains the slicer filter fields. Let's say that my test data uses slicer_value for field filtering.
The idea is that you can add the slicer column to the model, and then form a new column (which doesn't actually have a real value) by stitching together each of the values in the To and From columns in a string splice.
A new column (not actually created, but by way of a var variable), determine if the value in the slicer is in the From or To column, and if it is, then categorize it and return a different [BarrierFeet] column The processed value (either the original value or the corresponding negative value)

 

 

C_FormAllValues = 
  VAR _Form_allvalue=CONCATENATEX(
    VALUES('Test_table'[From]),
    [From],
    ","
  )
  VAR _To_allvalue=CONCATENATEX(
    VALUES('Test_table'[To]),
    [To],
    ","
  )
 RETURN
 IF(CONTAINSSTRING(_Form_allvalue,[slicer_value]),[BarrierFeet]*-1,
        IF(CONTAINSSTRING(_To_allvalue,'Test_table'[slicer_value]),[BarrierFeet],BLANK())
 )

 

 

vjtianmsft_1-1721624891621.png

 

vjtianmsft_3-1721624937675.png

 

This method can fulfill your needs to some extent, but you need to make sure that the data source and slicer values are correct and consistent. If you have a large amount of data, it is recommended that you test the performance in real applications to ensure that it does not affect the responsiveness of the reports, so you can try it out and use it as an alternative.
If you think my suggestion is a good one to try, it would be a good idea to pre-process the data in the data source to minimize the need to re-create calculated columns when creating a new report.

As a matter of fact, after communicating your requirements to the team, I came to the conclusion that it is possible to create a MEASURE but not a physical column (calculated column) because the slicer itself is a VISUAL and its values are dependent on other columns, but the reverse does not hold true, you cannot create a calculated column with fixed operations by using the dynamic values of the slicer, which is illogical!
You need to make sure that the data requirements are met in the physical columns before you can create a virtual table or perform string splice matching to fulfill your needs.
I wish you the best of luck in finding a suitable solution.

 

I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.

Best Regards,

Carson Jian,

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Ritaf1983
Super User
Super User

Hi @lsealy 

Can you please share a pbix or some dummy data that keep the raw data structure with expected results? It should help us clarify your scenario and test to coding formula.

How to Get Your Question Answered Quickly  

 

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Yes, thank you for the helpful instructions. I did download a .pbix and place a link in my post, but I'm new at this, so if you can't open the report please let me know. The issue resides on the 'Barrier-Job' page of the report. I did remove the BarrierFtFromTo custom column because the formula wasn't working, but I do need the column as described above, and need to associate the running total custom column to the new custom column.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors