Forum Discussion

Juliet1's avatar
Juliet1
Frequent Visitor
3 years ago
Solved

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

  • Hi,

    This is my solution :

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

    2- Append 2 tables and delete :

    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  :

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

1 Reply

  • MahyarTF's avatar
    MahyarTF
    Memorable Member

    Hi,

    This is my solution :

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

    2- Append 2 tables and delete :

    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  :

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