cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
jonclay
Helper I
Helper I

How to use Conditional Format to make a country into ""

Hello

Our database holds lots of addresses with the Country as United Kingdom. I'd like to use Power BI's Conditional Formatting function to make these into blanks. We use the lists extracted via Power BI to mail people, and we simply don't want the country to appear if it's United Kingdom, but we would like the Country to show if it's e.g. Italy or Spain etc.

I've tried creating a Measure using the following criteria, but I don't think it's going to work as it's been running for 20 minutes so far!

Measure = VAR Country = SELECTEDVALUE(contact[address1_country])
RETURN IF(Country="United Kingdom", Country, "")
Does anyone have a better idea as to how I could achieve this?
 
Many thanks
Jon
2 ACCEPTED SOLUTIONS

@jonclay actually, that's the really cool thing about power query (the transform data screen), it will apply that step on all new data that comes in too 🙂

Respectfully,
DataZoe


See my reports and blog at https://www.datazoepowerbi.com/

View solution in original post

v-henryk-mstf
Community Support
Community Support

Hi @jonclay ,

 

According to your description, using the "replace value" function in power query is a good choice. As long as the data source is successfully connected, the above operations will still be performed automatically after refreshing the data.

vhenrykmstf_0-1632728753425.png

after refersh:

vhenrykmstf_1-1632728881783.png

Or the measure like below:

M =
IF (
    SELECTEDVALUE ( Sheet1[Column1] ) = "United Kingdom",
    MAX ( Sheet1[Column1] ),
    ""
)


If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.


Best Regards,
Henry


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

8 REPLIES 8
v-henryk-mstf
Community Support
Community Support

Hi @jonclay ,

 

According to your description, using the "replace value" function in power query is a good choice. As long as the data source is successfully connected, the above operations will still be performed automatically after refreshing the data.

vhenrykmstf_0-1632728753425.png

after refersh:

vhenrykmstf_1-1632728881783.png

Or the measure like below:

M =
IF (
    SELECTEDVALUE ( Sheet1[Column1] ) = "United Kingdom",
    MAX ( Sheet1[Column1] ),
    ""
)


If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.


Best Regards,
Henry


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

Thank you, Henry. Both of those work perfectly!

DataZoe
Super User
Super User

@jonclay It may be easier to

1. go back into "Transform Data"

2. on the "address1_country" column you can right-click it

3. choose "Replace Values"

4. replace "United Kingdom" with null or a space.

Respectfully,
DataZoe


See my reports and blog at https://www.datazoepowerbi.com/

Thanks @DataZoe 

The only problem with this is that the underlying data gets added to each day, so there will always be new records showing the Country of United Kingdom.

Thank you, Zoe. That works perfectly!

@jonclay actually, that's the really cool thing about power query (the transform data screen), it will apply that step on all new data that comes in too 🙂

Respectfully,
DataZoe


See my reports and blog at https://www.datazoepowerbi.com/

View solution in original post

amitchandak
Super User
Super User

@jonclay ,

You should use this on your measure

 

New Measure= VAR Country = SELECTEDVALUE(contact[address1_country])
RETURN IF(Max(Table[Country]) ="United Kingdom", [Measure], blank())

 

The country is used in grouped in visual  as row/column/axis

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!
Dashboard of My Blogs !! Connect on Linkedin

Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
Proud to be a Super User!

@amitchandak 

Thank you for your quick response. However, the [Measure] section towards the end of the statement is causing me a problem. Power BI is underlining it with a squiggly line and saying that Measure cannot be determined.

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

November Power BI Update 768x460.png

Check it Out!

Click here to read more about the November 2021 Updates!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.