Forum Discussion
Matheus_Giam
6 years agoNew Member
custom column, with the line average
how to create custom column, with the average of the row and not with the average of the column? (not counting zero/blank)
Client | jan | fev | mar | abr | create average
A | 2 | 0 | | | | 2
B | 4 | 3 | 1 | 0 | 2,66
C | 1 | 7 | 4 | 5 | 4,74
Client | jan | fev | mar | abr | create average
A | 2 | 0 | | | | 2
B | 4 | 3 | 1 | 0 | 2,66
C | 1 | 7 | 4 | 5 | 4,74
2 Replies
- amitchandak
Super User
Matheus_Giam , Looking at this data you better unpivot
https://radacad.com/pivot-and-unpivot-with-power-bi
Pivot using Matrix and have a Sun total Avg at the client using allexcept
https://community.powerbi.com/t5/Desktop/Percentage-of-subtotal/td-p/95390
- v-lili6-msft
Community Support
hi Matheus_Giam
Use this formula to add a custom column in power query:
List.Sum({[jan],[fev],[mar],[abr]})/ ( (if [jan] = null or [jan] = 0 then 0 else 1)+ (if [fev] = null or [fev] = 0 then 0 else 1)+ (if [mar] = null or [mar] = 0 then 0 else 1)+ (if [abr] = null or [abr] = 0 then 0 else 1) )Result:
and here is sample pbix file, please try it.
Regards,
Lin