Forum Discussion
Calculate an Custom Column based on Values of another Table
- 6 years ago
Hi RaptorFox ,
Try the measure.
Measure = VAR x = CALCULATE( SUM('Time Bookings'[ExternalTotalAmount]), ALLEXCEPT('Project Data', 'Project Data'[ProjectNumber]) ) VAR y = DIVIDE( x, SELECTEDVALUE('Project Data'[Budget]) ) RETURN yBest regards,
Lionel ChenIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- 6 years ago
Hi RaptorFox ,
In "Edit queries", we use M language which doesn't have the SUMX() function.
Power Query M function reference
But we can also use M language grouping aggregation.
Best regards,
Lionel ChenIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
parry2k Sure, thanks!
Sample Data for Table "Time Bookings"
| ProjectNumber | ProjectName | Employee | Date | Hours | ExternalRate | ExternalTotalAmount |
| 651232 | Project BI Implementation | Peter Miller | 01.04.2020 | 2.5 | 200 | 500 |
| 651889 | ERP Renewal | Tony West | 03.04.2020 | 5 | 200 | 1000 |
| 651232 | Project BI Implementation | Celine Wild | 20.04.2020 | 3 | 190 | 570 |
| … |
Sample Data for Table "Project Data"
| ProjectNumber | ProjectName | Budget |
| 651232 | Project BI Implementation | 50000 |
| 651889 | ERP Renewal | 30000 |
| … |
I expect a new row in the "Project Data" table which shows the calculated total amount of all the bookings in the "Time Bookings" table for the related project. The screenshot shows the underlying model and the relationship (the key is "ProjectNumber").
| ProjectNumber | ProjectName | Budget | UsedAmountTotal |
| 651232 | Project BI Implementation | 50000 | 1070 |
| 651889 | ERP Renewal | 30000 | 1000 |
| … |
RaptorFox I assume you have one to many relationships between these two tables, just add the following measure and it should work
Used Amount Total = SUM ( TimeBookings[ExternalTotalAmount )
- RaptorFox6 years agoFrequent Visitor
parry2k Thanks! Yes, this measure works, i already had it. But now, i would like to somehow calculate and show the percentage between budget and the calculated total amount, therefore i wanted to have the amount directly in the 'Project Data' table.
When i add the measure to the visual, i cannot show the proportion or percentage from the total amount to the budget, i just cannot get it done (might be and most probably is a usage issue):
- v-lionel-msft6 years ago
Community Support
Hi RaptorFox ,
Try the measure.
Measure = VAR x = CALCULATE( SUM('Time Bookings'[ExternalTotalAmount]), ALLEXCEPT('Project Data', 'Project Data'[ProjectNumber]) ) VAR y = DIVIDE( x, SELECTEDVALUE('Project Data'[Budget]) ) RETURN yBest regards,
Lionel ChenIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- RaptorFox6 years agoFrequent Visitor
With this measure, i was able to at least solve the most pressing business need for information about the project progress, thanks! I know that i was not very clear in stating my expectations in the very beginning and created some confusion. Sorry for that!
Just quickly back to my original question: Why am i not able to add a custom column summarizing all the "ExternalTotalAmount" for each project out of the data from the "Time Bookings" table and add those to the corresponding project in the my "Project Data" table by using the following query: