Forum Discussion
Lookup value from table_2 and sum it [DAX]
Hi,
my target is to sum the values from table_1 and insert them into table_2.
How can I do that with DAX?
Example is shown below:
Hi, Anonymous
You need to create a summarize table first (calcualted table)
Tab = SUMMARIZE(Table1,Table1[Name No],Table1[Name],"Cost",SUM(Table1[Costs]))Tehn using lookupvalue to create a calculated column.
C_Costs = LOOKUPVALUE(Tab[Cost],Tab[Name No],Table2[Name No],Tab[Name],Table2[Name])Best Regards,
Community Support Team _ Eason
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
4 Replies
- v-easonf-msft
Community Support
Hi, Anonymous
You need to create a summarize table first (calcualted table)
Tab = SUMMARIZE(Table1,Table1[Name No],Table1[Name],"Cost",SUM(Table1[Costs]))Tehn using lookupvalue to create a calculated column.
C_Costs = LOOKUPVALUE(Tab[Cost],Tab[Name No],Table2[Name No],Tab[Name],Table2[Name])Best Regards,
Community Support Team _ Eason
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.- sangeetaraman
Advocate I
Thank you, this was really helpful
- parry2k
Super User
Anonymous you should create a table for name dimension with unique values for the name and set relationship with both the tables, it will be one to many relationships, in visual, use name information from this new table and rest of the columns from the respective table. This is the right way to do this. Read this post
Understand star schema and the importance for Power BI - Power BI | Microsoft Docs
✨ Follow us on LinkedIn
Check my latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
⚡ Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.⚡
- Greg_ZRegular Visitor
I wanted to add an easier solution if others are looking for a solution to the same issue. The steps are listed based on the example provied (i.e. Table 1 and Table 2 in the screen shot).
- Under the Model View make sure there is a link between Table 1 and Table 2
- In this case it would be Table 1.Name No = Table 2.Name No
- In Table 2 create a new measure using the SUM dax
Here is a link to an example workbook with the Table 1 and Table 2 data set for reference
- Under the Model View make sure there is a link between Table 1 and Table 2