Forum Discussion

TiRohnCH's avatar
TiRohnCH
New Member
3 years ago
Solved

Create new Table based on two other tables

Hi there

 

I have two tables in my model, one with a list of distinct accounts, the other with a huge list of entries for hours per user on several more accounts.

Table 1:

Account KeyDescriptionOtherInfo
1Description 1Other 1Info 1
2Description 2Other 2Info 2

 

Table 2:

Account KeyDateUserhours
11.1.2023user12
12.1.2023user23
51.1.2023user13
63.1.2023user57

 

I would now like to create a new table with only the Accounts in Table 1 from Table 2, which would look like this...

 

Table 3:

Account KeyDateDescriptionUserHours

1

1.2.2023Description 1user12
12.1.2023Description 1 user23

 

How can I create this table? I tried CALCULATETABLE with filters but don't get it solved...

 

Thanks and regards

Martin

  • Hi TiRohnCH , to build your desired table, further to the DAX provided by johnt75 ,you can use the following DAX.

     

    Table = 
    VAR StagingTable = SUMMARIZE ('Table 2',
                                  'Table 1'[Account key],
                                  'Table 2'[Date],
                                  'Table 1'[Description],
                                  'Table 2'[User],
                                  'Table 2'[Hours]
    )
    VAR Result = FILTER(StagingTable,[Account Key]<>BLANK())
    RETURN
    Result

     

3 Replies

  • If you have a one-to-many relationship from Table 1 to Table 2 you could use

    Table 3 =
    SUMMARIZE (
        'Table 2',
        'Table 1'[Account key],
        'Table 2'[Date],
        'Table 1'[Description],
        'Table 2'[User],
        'Table 2'[Hours]
    )
    
    • TiRohnCH's avatar
      TiRohnCH
      New Member

      Excellent, thank you very much, that's how it works, the second solution without the blanks is the one I'll be using...

       

      Kind regards

      Martin

  • johnyip's avatar
    johnyip
    Icon for Solution Sage rankSolution Sage

    Hi TiRohnCH , to build your desired table, further to the DAX provided by johnt75 ,you can use the following DAX.

     

    Table = 
    VAR StagingTable = SUMMARIZE ('Table 2',
                                  'Table 1'[Account key],
                                  'Table 2'[Date],
                                  'Table 1'[Description],
                                  'Table 2'[User],
                                  'Table 2'[Hours]
    )
    VAR Result = FILTER(StagingTable,[Account Key]<>BLANK())
    RETURN
    Result