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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
mira_bella
Regular Visitor

Excluding rows based on combinations in another table

Hello,

 

I have a table with financial transactions: basically Account, Cost_center, and Amount.

I need to exclude the rows with certain combinations of Account + Cost_center. Since there are quite many, and there's no sensible logic in their numbering/naming, I decided to put the list of exceptions in another table, which would be just two columns: Account and Cost_center. (both relate as many to many, so the same Account is many times in the list and the same Cost center is many times in the list, but each combination is unique)

Then I need a function, which would look for matching combination in "Exceptions" for each row of my "Transactions" table. If it matches, the row should be excluded (or maybe just marked as "excluded" in additional column, which I then can use as filter) 

 

I'm new to PowerBI and "learning by doing" on my own, so I don't quite know how to do this in a better way. 

Adding a new query which will compare the tables and exclude rows?  

Or adding a searching function somewhere, which I then call in my calculation of a new column? somth like

IF exception_search=true then excluded_row=Yes.

 

But where and how to write such function/query? I'm not quite familiar with the syntax in PowerBI. I would be thankful for advice and code examples, or maybe just recommend me a link where to read..

2 ACCEPTED SOLUTIONS
MFelix
Super User
Super User

Hi @mira_bella,

 

Taking into account that you already did the auxiliary table yo need to do the following:

1 - Create a custom column in the Exceptions table with Account + Cost_center = ID.

2 - Create a custom column in the Financial transactions with Account + Cost_center = ID

With this two columns you can now make a merge between the two tables (vlookup in excel)

3 - In the Financial transaction choose option to Merge queries and be sure to select the Full outer (all rows from both)

4 - Chose expand on the column just created and select the ID then

5 - Filter out all that are not null.Merge.png


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

Thank you @MFelix! I managed to find the solution without combining columns. I did the "Merge query" selecting both Account and Cost center as matching columns in both tables, and setting the "Left Anti" join type (all rows from  Transactions except those which are also in Exceptions). Seems like it works correctly, comparing the final sums with our main reporting system.

 

Well that turned out to be easy, just as a newbie I couldn't figure out where to look for this feature 🙂 Hopefully helps someone else.

View solution in original post

3 REPLIES 3
MFelix
Super User
Super User

Hi @mira_bella,

 

Taking into account that you already did the auxiliary table yo need to do the following:

1 - Create a custom column in the Exceptions table with Account + Cost_center = ID.

2 - Create a custom column in the Financial transactions with Account + Cost_center = ID

With this two columns you can now make a merge between the two tables (vlookup in excel)

3 - In the Financial transaction choose option to Merge queries and be sure to select the Full outer (all rows from both)

4 - Chose expand on the column just created and select the ID then

5 - Filter out all that are not null.Merge.png


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



Thank you @MFelix! I managed to find the solution without combining columns. I did the "Merge query" selecting both Account and Cost center as matching columns in both tables, and setting the "Left Anti" join type (all rows from  Transactions except those which are also in Exceptions). Seems like it works correctly, comparing the final sums with our main reporting system.

 

Well that turned out to be easy, just as a newbie I couldn't figure out where to look for this feature 🙂 Hopefully helps someone else.

Hi @mira_bella,

Glad to hear the issue is solved. You can accept helpful replies as solution, this way, other community members would easily find the solution when they get same issues.

Besides, you can get more familiar with features in Power BI Desktop by reviewing different topics in the following link.

https://powerbi.microsoft.com/en-us/documentation/powerbi-desktop-get-the-desktop/


Thanks,
Lydia Zhang

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

Helpful resources

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