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
Anonymous
Not applicable

Joining two tables and applying year filter w/o using merge queries

Hi, I recently started using POWER BI and I am trying to do a single join as I would do in SQL. 

 

I have two tables: 

 

Table A
   
YearCustomer IDAccount ID
201810001
201820002
201830003
201840004
201810008
201820007
201830006
201740005

 

and 

 

Table B
  
Customer IDCustomer Name
1000A
2000B
3000C
4000D

 

The table that I want to get is a summary table showing the "Number of Accounts" by "Customer Name" where "thisyear" filter is applied (without explicitly typing 2018). 

 

Is this something that I can achieve without using merge queries but using a DAX function?

 

Table C
Customer NameNumber of Accounts
A2
B2
C2
D1

 

Thank you for the help!

Kerem

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @Anonymous,

 

You should use the relationship between tables to make this and then just add it to a table visual the Name from TableB and the Account from TableA.

 

For the account select the sumarization COUNT. 

 

If you add a filter based on year you can then get the expected result.

 

However if you don't want to have a slicer and just want to filter the count based on the current year without any selection you can add the following measure:

Number of accounts = CALCULATE(COUNT(TableA[Account ID]); TableA[Year] = YEAR(TODAY()))

Then use this measure on your table. Check below the two option on the image:

count.gif

 

Check attach PBIX file with example.

 

Regards.

MFelix


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

2 REPLIES 2
MFelix
Super User
Super User

Hi @Anonymous,

 

You should use the relationship between tables to make this and then just add it to a table visual the Name from TableB and the Account from TableA.

 

For the account select the sumarization COUNT. 

 

If you add a filter based on year you can then get the expected result.

 

However if you don't want to have a slicer and just want to filter the count based on the current year without any selection you can add the following measure:

Number of accounts = CALCULATE(COUNT(TableA[Account ID]); TableA[Year] = YEAR(TODAY()))

Then use this measure on your table. Check below the two option on the image:

count.gif

 

Check attach PBIX file with example.

 

Regards.

MFelix


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



Anonymous
Not applicable

Hi @MFelix thank you for your reply. It worked. And thanks for showing the solution in two different ways. I used the measure. 

 

Very helpful!

Kerem

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.