Forum Discussion
powerbienthuzi
4 years agoFrequent Visitor
Simple GroupBy Question
Hello - I am trying to group people with the same period to show the summed value of compensation. So for instance, this employee example should show 14505 in period one. My current approach use...
- 4 years ago
powerbienthuzi looks like you need a derivedTbl, Can you try this
derivedTbl= groupby(PnL_Data, PnL_Data[deID], PnL_Data[pstartdate], PnL_Data[pperiod],"sum", SUMX(CURRENTGROUP(),PnL_Data[AccruedCompensation]))SUMAMRIZE has more layers than it looks
https://www.sqlbi.com/articles/all-the-secrets-of-summarize/
powerbienthuzi
4 years agoFrequent Visitor
I see. I have deleted my code for groupby and am trying to get it in a table format using Summary now
Short PnL = SUMMARIZE(PnL_Data,
PnL_Data[deID],
PnL_Data[pstartdate],
PnL_Data[pperiod],
"total compensation", SUM(PnL_Data[AccruedCompensation])
)
but the aggregation is not adding up right so I'm sure I made a mistake.
This is the picture of the result I'm getting:
ā
AlexisOlson
4 years agoSuper User
Does your PnL table have any filters you want that didn't get included when you summarized it?
- powerbienthuzi4 years agoFrequent Visitor
Hi Alexis - It has no filters that I needed.
- smpa014 years agoCommunity Champion
powerbienthuzi looks like you need a derivedTbl, Can you try this
derivedTbl= groupby(PnL_Data, PnL_Data[deID], PnL_Data[pstartdate], PnL_Data[pperiod],"sum", SUMX(CURRENTGROUP(),PnL_Data[AccruedCompensation]))SUMAMRIZE has more layers than it looks
https://www.sqlbi.com/articles/all-the-secrets-of-summarize/
- powerbienthuzi4 years agoFrequent Visitor
That worked. Thank you!