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
LasseA
Helper I
Helper I

Filter out the correct customer city from column

Dear all, 

 

I hope you can help me understand how i filter the relevant customer city from a "city column" which includes the many more cities besides the customercity. This could be the destination city, flight departure city etc. 

 

In excel i use to use this formula:

 

=IF.ERROR(VLOOKUP(A2;'HELPINGCOLUMN'!$B:$C;2;FALSE);"NOT FOUND")

 

Here i use a helping column i have created that includes the region "europe" and the difference cities that are. If no cities are found my formula returns "not found"

 

My datatable in power bi has 100's of columns. I therefor hope i can do this as a measure. 

 

I want to filter out the customer city for each order number.

 

My table has many different cities and prices and productcodes, these are all connected to order numbers, which is why there are more order numbers that are the same. 

 

The columns i believe are relevant to filter out the customer city are:

 

"OrderNumber"

"City"

"Region"

 

The customer city i am looking for is under the region "Europe".

 

How do i do this? Which measure am i to use to filter out the customer city?

 

If there is more than 1 customer city in the "Europe" region, then how do i choose only one?

 

Thanks in advance. 

7 REPLIES 7
v-danhe-msft
Employee
Employee

Hi @LasseA,

Could you please offer me some sample data to have a test and post your desired result if possible?

 

Regards,

Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-danhe-msft

 

Order NumberProductCity CountryRegion Desired output 
51100Flight JohannesburgSouth AfricaAfrica 
51100FlightLondon United KingdomEurope London
51100TaxJohannesburgSouth AfricaAfrica 
51100HotelJohannesburgSouth AfricaAfrica 
51101Flight JohannesburgSouth AfricaAfrica 
51101FlightParisFranceEurope Paris 
51101FlightNiceFranceEurope  
51101TaxJohannesburgSouth AfricaAfrica 
51101HotelJohannesburgSouth AfricaAfrica 
51102Flight JohannesburgSouth AfricaAfrica 
51102FlightBremenGermanyEurope Bremen 
51102TaxJohannesburgSouth AfricaAfrica 
51102HotelJohannesburgSouth AfricaAfrica 


i cannot offer the real data, so i have tried to make a small sample of my big dataset. 

 

There are MANY more columns and lines for each order number which also contains different cities and regions etc. 

 

I hope this can give you a overview of what i am trying to write in dax. 

 

I prefer it as a measure and not a calculated column which i have here in the sample. 

 

Thank you so much 🙂

Hi @LasseA,

Based on my test, you could refer to below formula:

Measure = IF(CALCULATE(MAX([Region ]))="Europe",CALCULATE(MAX([City ])),BLANK())

Result:

1.PNG

And I could not understand that the "Nice" city is under the region of "Europe", should it be your desired result?

You could also download the pbix file to have a view.

 

Regards,

Daniel He 

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hello @v-danhe-msft

 

Have you gotten around to look at this one mor time?

 

I hope you will be able to help me with the additional information i provided. 

 

Thank you again, 

 

Best regards, 

Lasse

Hello @v-danhe-msft

 

Thank you so much. 

 

Regarding order number 51101 with 2 cities under the region "europe" my point was that only the city Paris should be output, because i need only 1 city per order number.

 

I need in my visualization to show the order number only once, with 1 city. 

 

I hope you understand what i mean and can help me accomplish this task. 

 

Thank you so much in advance for your help

 

Best regards, 

Lasse

@v-danhe-msft

Furthermore, the dax code you provided, unfortunately does not work. 

 

When only picking the order numer and the new measure it reveals that the syntax is wrong because order number 51102 reveals "Johannesburg" which is clearly not under the region europe. 

 

I hope you can help me solve this matter.

 

Thanks in advance and best regards 

Lasse

Dear all, 

 

I hope you can help me understand how i filter the relevant customer city from a "city column" which includes the many more cities besides the customercity. This could be the destination city, flight departure city etc. 

 

In excel i use to use this formula:

 

=IF.ERROR(VLOOKUP(A2;'HELPINGCOLUMN'!$B:$C;2;FALSE);"NOT FOUND")

 

Here i use a helping column i have created that includes the region "europe" and the difference cities that are. If no cities are found my formula returns "not found"

 

My datatable in power bi has 100's of columns. I therefor hope i can do this as a measure. 

 

I want to filter out the customer city for each order number.

 

My table has many different cities and prices and productcodes, these are all connected to order numbers, which is why there are more order numbers that are the same. 

 

The columns i believe are relevant to filter out the customer city are:

 

"OrderNumber"

"City"

"Region"

 

The customer city i am looking for is under the region "Europe".

 

How do i do this? Which measure am i to use to filter out the customer city?

 

If there is more than 1 customer city in the "Europe" region, then how do i choose only one?

 

Order NumberProductCity CountryRegion Desired output 
51100Flight JohannesburgSouth AfricaAfrica 
51100FlightLondon United KingdomEurope London
51100TaxJohannesburgSouth AfricaAfrica 
51100HotelJohannesburgSouth AfricaAfrica 
51101Flight JohannesburgSouth AfricaAfrica 
51101FlightParisFranceEurope Paris 
51101FlightNiceFranceEurope  
51101TaxJohannesburgSouth AfricaAfrica 
51101HotelJohannesburgSouth AfricaAfrica 
51102Flight JohannesburgSouth AfricaAfrica 
51102FlightBremenGermanyEurope Bremen 
51102TaxJohannesburgSouth AfricaAfrica 
51102HotelJohannesburgSouth AfricaAfrica 


i cannot offer the real data, so i have tried to make a small sample of my big dataset. 

 

There are MANY more columns and lines for each order number which also contains different cities and regions etc. 

 

I hope this can give you a overview of what i am trying to write in dax. 

 

I prefer it as a measure and not a calculated column which i have here in the sample. 

 

Thank you so much Smiley Happy

 

Thanks in advance. 

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.