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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
smjzahid
Helper V
Helper V

How to swap static TEXT box values in a report page when user changes filter

Hi All,

 

I have a pbix file which has a filter applied to it at PAGE LEVEL. I would like to swap the values shown within the TEXT BOX when ever user interacts with the filter for eg: when the user select 13 Period Rolling I would like to show below value inside the TEXT BOX (see first snip)

 

image.png

 

When the user select SECTION 2A I want the above TEXT BOX to display below shown value

smjzahid_1-1620326174883.png

and so on for other values available in the filter. I tried using BOOKMARK without any success, as I believe the above is just a TEXT BOX which has been hard coded with test values written inside it, 

 

Do we have a way to achieve this functionality in Power BI, any help is highly appreciated. Many Thanks

2 ACCEPTED SOLUTIONS

Hi @HarishKM 

 

DisplayText = 

IF ( HASONEVALUE('Close Call Analysis P13 - 13 Period Rolling'[Area Type]), 

SWITCH( TRUE (),

SELECTEDVALUE('Close Call Analysis P13 - 13 Period Rolling'[Area Type]) = "Section 2A", "Excluding: Site Welfare, Site Housekeeping: 88",

SELECTEDVALUE('Close Call Analysis P13 - 13 Period Rolling'[Area Type]) = "13 Period Rolling", "Excluding, Site Welfare, Site Housekeeping: 378",

etc),
BLANK())

 

If this is what you need, please mark as a solution.

 

Hope this helps

David

View solution in original post

You'll need an empty string to close out SWITCH and another to close out IF

 

IF ( ... , SWITCH ( ... , ""), "")

View solution in original post

14 REPLIES 14
v-luwang-msft
Community Support
Community Support

Hi @smjzahid ,

Has your problem been solved, if so, please consider Accept a correct reply as the solution to help others find it.  
 
Best Regards
Lucien
HarishKM
Impactful Individual
Impactful Individual

@smjzahid  Use below Dax  

test 2 = (SELECTEDVALUE(financials[Country]))
 

HarishKM_0-1620385531942.png

 

Hi @HarishKM 

 

That not the what I am after, as I mentioned earlier I have a column named (Area Type) as a text datatype and I am using this as a filter in my report, so what I would like to acheive is whenver the user selects a report from this filter (see below snip)

image.png

 

and when the user selects a different filter I want to change the values in the TEXT BOX field (see snip highlighted showing values as (Excluding Site Welfare, Site Housekeeping) for eg< If user selects SECTION 2A from the filter I want the TEXT BOX to show a different value. 

 

smjzahid_0-1620817686911.png

I want to show below values (seen snip below in TEXT BOX)

 

image.png

Hi @HarishKM 

 

DisplayText = 

IF ( HASONEVALUE('Close Call Analysis P13 - 13 Period Rolling'[Area Type]), 

SWITCH( TRUE (),

SELECTEDVALUE('Close Call Analysis P13 - 13 Period Rolling'[Area Type]) = "Section 2A", "Excluding: Site Welfare, Site Housekeeping: 88",

SELECTEDVALUE('Close Call Analysis P13 - 13 Period Rolling'[Area Type]) = "13 Period Rolling", "Excluding, Site Welfare, Site Housekeeping: 378",

etc),
BLANK())

 

If this is what you need, please mark as a solution.

 

Hope this helps

David

Hi @dedelman_clng,

 

Many Thanks for your updated DAX code on this, Yes this does works and this is what I want. However, when the user selectes any other option from the filter ( other than the one mentioned in below DAX code below 

 

DisplayText = 
IF ( HASONEVALUE('Close Call Analysis P13 - 13 Period Rolling'[Area Type]), 

SWITCH( TRUE (),

SELECTEDVALUE('Close Call Analysis P13 - 13 Period Rolling'[Area Type]) = "Section 2A", "Excluding: Site Welfare, Site Housekeeping: 88",

SELECTEDVALUE('Close Call Analysis P13 - 13 Period Rolling'[Area Type]) = "13 Period Rolling", "Excluding: Site Welfare, Site Housekeeping: 378",

SELECTEDVALUE('Close Call Analysis P13 - 13 Period Rolling'[Area Type]) = "Section 2B", "Excluding: Site Welfare, Site Housekeeping: 112",

SELECTEDVALUE('Close Call Analysis P13 - 13 Period Rolling'[Area Type]) = "Section 2C", "Excluding: Site Welfare, Site Housekeeping: 126",

BLANK()))

 

I DO NOT want to show anything on the visual (not eveen BLANK) appearing inside the CARD visual

image.png

Replace BLANK() with empty string "" and that should give you what you want.

That's awesome, works perfect. 

 

Appreciate your reply

Thanks @dedelman_clng 

 

Yes already tried that option before posting reply to this thread. Still appear as BLANK,

 

when the user DO NOT select any filter 

 

image.png

 

 

 

 

smjzahid_0-1620988555736.png

 

You'll need an empty string to close out SWITCH and another to close out IF

 

IF ( ... , SWITCH ( ... , ""), "")

dedelman_clng
Community Champion
Community Champion

Hi @smjzahid -

 

Usually in this situation you would create a measure that returns the text that you want, based on the filter selection, and then put that measure in a Card visual. The formatting options in a card aren't quite the same as in a text box, but you should be able to get mostly what you want.

 

The measure would be along the lines of

 

DisplayText = IF ( HASONEVALUE([Your Filter]), 

SWITCH( TRUE (),

Filter Condition 1, "Text string 1",

Filter Condition 2, "Text string 2",

...)

 

Hope this helps

David

Hi @dedelman_clng 

Thanks for your help, I tried to apply above measure but it throws below error. Please note in my report there is a TEXT column named Area Type which has the filter values that users will be picking from  for example (see below)

 

image.png

 

image.png

DisplayText = IF ( HASONEVALUE([Your Filter]), 

SWITCH( TRUE (),

[Your FIlter Column] = "FIlter Condition 1", "Text string 1",

[Your Filter Column] = "Filter Condition 2", "Text string 2",

...)

 

Also be sure to create it as a measure, not a calculated column.

Hi,

 

Its not letting me enter the name of my Filter Column as per your above revised code.

 

When I key in the name manually it undeline with a red colour, Its only allow measures in that location to be entered

 

and yes I am creating a measure (NOT calculated column)

 

image.png

[Your Filter Column] must include the table name, just like any other time the column is referenced in any piece of DAX code.

 

'Close Call Analysis P13 - 13 Period Rolling'[Area Type]

 

You can also try wrapping the full column name in SELECTEDVALUE()

 

SELECTEDVALUE('Close Call Analysis P13 - 13 Period Rolling'[Area Type]) = "XXX", "YYY"

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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