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.
Table 1: (ID Primary Key, Value)
ID (Primary Key) | Value |
1 | 100,000 |
2 | 50,000 |
3 | 100,000 |
4 | 50,000 |
Table 2: (ID)
ID |
1 |
1 |
1 |
2 |
2 |
To calculate sum of the Column: Table 1 [Value] based on the distinct values from Table 2.
Logic:
1. Create a measure on Table 1 which can return the sum of Table 1 [Value]
ID (DISTINCT from Table 2) | Value (Table 1) |
1 | 100,000 |
2 | 50,000 |
Solved! Go to Solution.
Hi @parameswaran ,
Can you create a relationship between two tables? If you can, I created a sample that maybe help you.
Measure = CALCULATE(SUM('Table 1'[Value]),FILTER('Table 1','Table 1'[ID (Primary Key)] in VALUES('Table 2'[ID])))
Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
This can be done using groupby
https://docs.microsoft.com/en-us/dax/groupby-function-dax
Hi @amitchandak : thanks for your input. GROUPBY() is not appropriate here as it returns a new table not as a measure and CURRENTGROUP() can operate only on aggregate functions like SUMX.
To give some idea, here is the look of the measure I'm working but this is wrong..
Final Sum =
CALCULATE(
ADDCOLUMNS(
DISTINCT (Table 2[ID]),
"Result",
var T1_ = SELECTCOLUMNS (Table 1, "Total Value", [Value])
var T2_ = DISTINCT('Table 2'[ID])
RETURN
SUM(INTERSECT (T1_, T2_))
),
[Result]
)
NOTE: This is simplified form of the problem of the complex scenario, I'm working on. If the expected output is not in the form of a measure, it's not really helpful for me. Thanks for understanding.
Hi @parameswaran ,
Can you create a relationship between two tables? If you can, I created a sample that maybe help you.
Measure = CALCULATE(SUM('Table 1'[Value]),FILTER('Table 1','Table 1'[ID (Primary Key)] in VALUES('Table 2'[ID])))
Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
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 |
---|---|
107 | |
99 | |
76 | |
64 | |
58 |
User | Count |
---|---|
148 | |
113 | |
97 | |
84 | |
67 |