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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Juliet1
Frequent Visitor

Create a table based on two tables

Hi Team

 

I have two tables that I need to combine based on a year criteria.

Table 1 shows the number or items sold during  certain year, and the Table 2 is the database created after 2019 that contains the list of items sold sice 2019.

Table 1

YearNumber
20165
20178
201810

 

Table 2

 

DateRef
12/May/201910
13/Apr/201911
1/Oct/201910
8/Jun/20201
10/Jan/202107
10/Jun/202110

 

I need to create a table that will fetch the data in the column Number from the table 1 for the years 2016 to 2018 and for 2019 and forward the sum of the number of items sold during those years.

 

Result

Year# Articles sold
20165
20178
201810
20193
20201
20212

 

 

Thanks a lot for your help

1 ACCEPTED SOLUTION
MahyarTF
Memorable Member
Memorable Member

Hi,

This is my solution :

1- In Table 2 I create the Year column based on the date column in Power Query :

MahyarTF_0-1664923522307.png

2- Append 2 tables and delete :

MahyarTF_1-1664923587537.png

3- Create the below measure in new table :

# Article Sold = if(SELECTEDVALUE('Sheet220-1'[Number]) <> BLANK(),
                    SELECTEDVALUE('Sheet220-1'[Number]),
                    CALCULATE(COUNT('Sheet220-1'[Year]))
                )
Now could use the measure in Table visual or anywhere  :
MahyarTF_2-1664923810680.png

Thanks for Kudos and please mark it as solution if it helps

Mahyartf

View solution in original post

1 REPLY 1
MahyarTF
Memorable Member
Memorable Member

Hi,

This is my solution :

1- In Table 2 I create the Year column based on the date column in Power Query :

MahyarTF_0-1664923522307.png

2- Append 2 tables and delete :

MahyarTF_1-1664923587537.png

3- Create the below measure in new table :

# Article Sold = if(SELECTEDVALUE('Sheet220-1'[Number]) <> BLANK(),
                    SELECTEDVALUE('Sheet220-1'[Number]),
                    CALCULATE(COUNT('Sheet220-1'[Year]))
                )
Now could use the measure in Table visual or anywhere  :
MahyarTF_2-1664923810680.png

Thanks for Kudos and please mark it as solution if it helps

Mahyartf

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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