Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hello,
I would add column values from two different tables
Sum Total Sales column if Table1 Account field is equal to Table 2 Account field. When I run the below query, its provided me sum of all the accounts.
Column = If('Table1'[T1Account] = RELATED(Table2[T2Account]), Sum('Table1'[Sales]))
Edit: Added Relationship
Table 1 Table 2
Account * : 1 Account
Thanks in advance
Solved! Go to Solution.
Hi @Anonymous ,
Based on the one to many relationship you have created. You can use the CROSSFILTER function to calculate the expect result.
Try to create calculated column or measure like this:
Column = CALCULATE(SUM(table1[Sales]),CROSSFILTER(table2[T2Account],table1[T1Account],OneWay))
Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@Anonymous , Try a new column in Table 2 like
sumx(filter(Table1, table1[T1Account]=Table2[T2Account]),Table1[Sales])
After working through your queries. I have identified that I am looking for something else
If MainAccount is equal to SubAccount then Sum all Sales of all Sub Accounts and display MainAccount , SubAccount and Sum of all Sales
I am trying following query in new column but giving unexpected parementer error for Sales column
Sumx(FILTER('Account_Sales','Account_Sales'[MainAccount]= 'Account_Sales'[SubAccount],[Sales])
Hi @Anonymous ,
Based on the one to many relationship you have created. You can use the CROSSFILTER function to calculate the expect result.
Try to create calculated column or measure like this:
Column = CALCULATE(SUM(table1[Sales]),CROSSFILTER(table2[T2Account],table1[T1Account],OneWay))
Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous ,
you can try this formula:
SumOfSales = CALCULATE(
SUM(Table1[Sales]),Table1[AccountID]=RELATED(Table2[AccountID]),ALLEXCEPT(Table1,Table1[AccountID])
)
Hope it helps.
Cheers,
Marco
Sounds like the tables aren't related. Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490
Hi Greg,
Both columns have similar values but coming from two different tables. Sum is adding all the columns in the table instead where Table 1 Account is equal to Table 2 Account
Thanks
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
106 | |
98 | |
78 | |
64 | |
58 |
User | Count |
---|---|
148 | |
113 | |
97 | |
84 | |
67 |