Forum Discussion
Adding specific vales to a filtered table
Hi Everyone
I have a table call Customer Table, that has customer names and their Region. I cannot edit the table due to it being a corporte database. The problem i am trying to solved is that when i filter for North America, the table will filtred but there are a 2 customers names in the mexico region, that i need to include in the filter when I filter for North America. I would appreciateany thoughts or ideas how to do this.
- Anonymous5 years ago
hi, for this specific case, you could create a calculate column in PowerBI with the next formula:
Region2 = IF( OR('Customer Table'[Region] = "North America",
OR('Customer Table'[Customer Name] = "Customer Nmae 7",
'Customer Table'[Customer Name] = "Customer Nmae 8")
),"North America",'Customer Table'[Region])You also can create a flag column based in 'Customer Name' Column, and then create a formula with the region and flag column.
Customer Name | Region | Flag (Based on Customer Name)
Customer Name 1 | North America | 0
Customer Name 2 | North America | 0
.
.
Customer Name 7 | Mexico | 1
Customer Name 8 | Mexico | 1
Customer Name 9 | Mexico | 0
Customer Name 10 | Mexico | 0
Region 2 = If( OR('Customer Table'[Region] = "North America", 'Customer Table'[Flag] = 1),
"North America", 'Customer Table'[Region])
Regards
4 Replies
- AnonymousNot applicable
hi, for this specific case, you could create a calculate column in PowerBI with the next formula:
Region2 = IF( OR('Customer Table'[Region] = "North America",
OR('Customer Table'[Customer Name] = "Customer Nmae 7",
'Customer Table'[Customer Name] = "Customer Nmae 8")
),"North America",'Customer Table'[Region])You also can create a flag column based in 'Customer Name' Column, and then create a formula with the region and flag column.
Customer Name | Region | Flag (Based on Customer Name)
Customer Name 1 | North America | 0
Customer Name 2 | North America | 0
.
.
Customer Name 7 | Mexico | 1
Customer Name 8 | Mexico | 1
Customer Name 9 | Mexico | 0
Customer Name 10 | Mexico | 0
Region 2 = If( OR('Customer Table'[Region] = "North America", 'Customer Table'[Flag] = 1),
"North America", 'Customer Table'[Region])
Regards
- parry2k
Super User
Anonymous why not create a new column in PQ for the region with the following expression and then remove the old region column and use the new one
if [Region] = "Mexico" then "North America" else [Region]✨ Follow us on LinkedIn
Check my latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
⚡ Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.⚡
- AnonymousNot applicable
Hi Parry2k, its a corprate database and cannot add or delete columns. I thought about that but found out that IT will not allow this. Thanks
- parry2k
Super User
Anonymous I'm suggesting adding a column in PQ, not in the database, and most of the time it is a good idea to create views in the backend and have that logic go in the view.