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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

need help to create a category field

Hi,

 

I needed to categorise passengers based on his flight origin country and flight destination country as Domestic, International Arrival and International Departure. 

The below is the sample dataset :

 

origin  countrydestination countryCategory
IndiaIndiaDomestic
USIndiaInternational Arrival
IndiaGermanyInternational Departure

 

please help me how to achieve this.

 

thanks

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

Try this calculated column formula

=if(Data[Destination Country]="India",if(Data[Origin Country]="India","Domestic","International Arrival"),"International Departure")

The assumption in this formula is that India will always be in a row (either in the Origin Country column or in the Destination Country column i.e. there will never be a case like Sweden and Germany in the same row)

Hope this helsp.


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

View solution in original post

5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

Try this calculated column formula

=if(Data[Destination Country]="India",if(Data[Origin Country]="India","Domestic","International Arrival"),"International Departure")

The assumption in this formula is that India will always be in a row (either in the Origin Country column or in the Destination Country column i.e. there will never be a case like Sweden and Germany in the same row)

Hope this helsp.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
mahoneypat
Microsoft Employee
Microsoft Employee

Please try this expression in your column 

 

Category = SWITCH(TRUE(), Table[origin country] = Table[destination country], "Domestic",

Table[origin country] = "US", "International Arrival",

"International Departure")

 

If this works for you, please mark it as solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Anonymous
Not applicable

Hi @mahoneypat ,

 

this solution works correct logically but it shows one more category as blanks when use this as a slicer. why this shows blank and how can we remove this?

 

Thanks

Not sure what you are seeing.  The way it is written, every row should at least have "International Departure", as it is the default output of SWITCH.   In any case, you could use this instead in case you have any scenarios that aren't covered by the current logic.  Does this table have a relationship with another table?  Does that table have rows in the relationship column that don't exist in this table?

 

Category = SWITCH(TRUE(), Table[origin country] = Table[destination country], "Domestic",

Table[origin country] = "US", "International Arrival", Table[origin country] <> "US",

"International Departure", "Other")

 

If this works for you, please mark it as solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


vanessafvg
Super User
Super User

you can use the switch statement or an if statement, what are you struggling with exactly?

 

https://docs.microsoft.com/en-us/dax/switch-function-dax

https://www.youtube.com/watch?v=-ykkaAtlCMc





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors