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
gauravnarchal
Post Prodigy
Post Prodigy

Calculated column

Hello All 

 

I need your help in creating the calculated column as below.

 

If Table 1 Product Code = Table 2 Product code

and

Table 1 product type 16  = “1” in (table 3 city type)

then

Match

Table 2 city code with Table 3 city code and return table 3 country

 

Else return the country from “0” in (table 3 city type)

 

For any errors or mismatches return the value as “Mismatch”

 

Table 1 Table 2 Table 3
Product CodeProduct Type Product CodeCity Code City TypeCityCountry
010 0AAC 0AACAFRICA
111 1AAE 0AAEAFRICA
212 2AAE 1AAEMALDIVES
316 3GLE 1AAIMALDIVES
9 REPLIES 9
v-xulin-mstf
Community Support
Community Support

Hi @gauravnarchal ,

 

Is your issue solved?

I'm not sure about the logic of 'Table 1 product type 16  = “1” in (table 3 city type)'.

Could you provide more details?

 

Best Regards,

Link

 

Is that the answer you're looking for? If this post helps, then please consider Accept it as the solution. Really appreciate!

ryan_mayu
Super User
Super User

@gauravnarchal 

not clear about this. Could you please separate the table in different rows? It's hard to understand how many columns in each table





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




@ryan_mayu - Here is how the data look like in the separate tables.

 

Thank you

 

Table 1

 

Product CodeProduct Type
010
111
212
316

 

Table 2

 

Product CodeCity Code
0AAC
1AAE
2AAE
3GLE

 

Table 3

 

City TypeCityCountry
0AACAFRICA
0AAEAFRICA
1AAEMALDIVES
1AAIMALDIVES

@gauravnarchal 

which column is the expected result?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi @ryan_mayu Please see below.

 

If Table 1 Product Code = Table 2 Product code

and

Table 1 product type 16  = “1” in (table 3 city type)

then

Match

Table 2 city code with Table 3 city code and return table 3 country

 

Else return the country from “0” in (table 3 city type)

 

For any errors or mismatches return the value as “Mismatch”

 

DATA

 

Table 1 
Product CodeProduct Type
010
111
212
316

 

Table 2 
Product CodeCity Code
0AAC
1AAE
2AAE
3GLE
5AMR
028JU
0JKLW
0"2JK

 

Table 3  
City TypeCityCountry
0AACAFRICA
0AAEAFRICA
1AAEMALDIVES
1AAIMALDIVES
0GLEINDONESIA
1GLEBHUTAN

 

RESULT

 

Table 2  
Product CodeCity CodeCountry
0AACAFRICA
1AAEAFRICA
2AAEAFRICA
3GLEBHUTAN
5AMRMISMATCH
028JUMISMATCH
0JKLWMISMATCH
0"2JKMISMATCH

@gauravnarchal 

still not clear about the calculation logic. 

do you mean check the product code in table 1 based on the product code in table 2?

the line 4, we can see 3 in table 1 , then we found the corresponding product type which is 16. 16 =1, then go to table 3 check city type is 1.

Then what about 10 11 12?

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi,

In which Table do you want to see that calculated column?  In that table, show the expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
viviank
Resolver I
Resolver I

I know this isn't directly answering your question, but I recommend setting up the relationship in the data model itself. Link the Product Codes together in the data model, and link the City Codes together in the model.

 

If you do that, then you don't need a formula, you can simply grab the Country code and it will work automatically.

 

If you need to filter by Product Type 16, you can add that as a filter to the visual.

@viviank - I need to create a calculated column for getting the desired result.  The visual filter will not work.

 

Also, in table 3 there are cities which had got different countries.

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.