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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.