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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
jonclay
Helper IV
Helper IV

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
DataZoe
Microsoft Employee
Microsoft Employee

@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,
Zoe Douglas (DataZoe)



Follow me on LinkedIn at https://www.linkedin.com/in/zoedouglas-data
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.

Thank you, Henry. Both of those work perfectly!

DataZoe
Microsoft Employee
Microsoft Employee

@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,
Zoe Douglas (DataZoe)



Follow me on LinkedIn at https://www.linkedin.com/in/zoedouglas-data
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!

DataZoe
Microsoft Employee
Microsoft Employee

@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,
Zoe Douglas (DataZoe)



Follow me on LinkedIn at https://www.linkedin.com/in/zoedouglas-data
See my reports and blog at https://www.datazoepowerbi.com/

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

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

@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
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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