cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

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

@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.

Thank you, Henry. Both of those work perfectly!

DataZoe
Microsoft
Microsoft

@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/

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

@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
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

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

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors