Forum Discussion
Calculate based on other columns
Hello,
I have this similar dataset:
| Id | Task | Progress | Id Main task |
| 1 | Main task 1 | ? | |
| 2 | Sub task 1 | 55 | 1 |
| 3 | Sub task 2 | 20 | 1 |
| 4 | Main task 2 | ? | |
| 5 | Sub task 1 | 10 | 4 |
| 6 | Sub task 2 | 0 | 4 |
| 7 | Sub task 3 | 95 | 4 |
| 8 | Main task 3 | ? | |
| 9 | Sub task 1 | 50 | 8 |
Intention is to find the average progress based on the sub tasks in each main task.
My start is: IF(Id main task = BLANK(), ??? Then I need to select all rows with id main task = Id and average these.
How to?
Thanks
Hello, Peavey
Try something like this:Average progress = var currentId = SELECTEDVALUE('Table'[Id]) var averageSubtasks = AVERAGEX(FILTER(ALL('Table'), 'Table'[ Id Main task] = currentId), 'Table'[ Progress]) return averageSubtasks
5 Replies
- PeaveyHelper III
Thanks for all the help, I found vojtechsima solution to fit my needs very well!
This community is so impressive, so much knowledge and helpful people here, many thanks again!
-A-
- vojtechsimaSuper User
Peavey Happy to help, kudos appreciated. Thank you too
- vojtechsimaSuper User
Hello, Peavey
Try something like this:Average progress = var currentId = SELECTEDVALUE('Table'[Id]) var averageSubtasks = AVERAGEX(FILTER(ALL('Table'), 'Table'[ Id Main task] = currentId), 'Table'[ Progress]) return averageSubtasks - ryan_mayuSuper User
what's the expected output based on the sample data you provided?
- AnonymousNot applicable
Hi Peavey ,
You can try formula like below to create calculate column and measure:
SubTaskProgress = IF(NOT(ISBLANK([Id Main task])), [Progress], BLANK())AverageProgress = CALCULATE( AVERAGE([SubTaskProgress]), ALLEXCEPT(TableName, TableName[Id Main task]) )Best Regards,
Adamk KongIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.