Forum Discussion
AVERAGE OF A SUM.....
Hi.
i have a table of customer:
co_cli fecha tc
0001 2020-01-01 1
0002 2019-06-30 1
003 2020-04-28 0
Where co_cli is the customer id, fecha is the register date and tc is 1 for active customer 0 inactive.
There is a date table call TABLA CALENDARIO, related with customer by FECHA (date).
With this DAX i get the active customers per month
NRO CLIENTES ACTIVOS =
CALCULATE (
SUM ( CLIENTES[tc]),
FILTER(CLIENTES,CLIENTES[fecha]<=MAX('TABLA CALENDARIO'[fecha])))
if i use distinctcount(co_cli) instead of this sum, i get the same result.
this solved. and we get:
AÑO= year
MES=month
NRO CLIENTS ACTIVOS= active customers
tc= sum(1 for active cliente 0 for inactive cliente)
año mes NRO CLIENTES ACTIVOS TC
2020 1 919 974
2020 2 954 974
2020 3 970 974
TOTAL 970 974
The result is correct.
the value of tc, 974 is the sum of ALL (tc) . in this case, includes month 4.
Now, we ned the average of NRO CLIENTES ACTIVOS.
If i apply AVERAGE , i get 323,33, which is 970/3.
But the formula i need is (919+954+970)/3=947.66
How i can aproach this?
Solved the problem
Well, go to sql and make a query with the info just how i needed into a new table in power bi.
Thanks
2 Replies
- amitchandak
Super User
rerangel , Seem like you need reverse of this
https://community.powerbi.com/t5/Desktop/SUM-of-AVERAGE/td-p/197013
Try Like - averagex(summarize(table,table[año],table[mes],"_1",[NRO CLIENTES ACTIVOS]),[_1])
- rerangel
Helper I
Solved the problem
Well, go to sql and make a query with the info just how i needed into a new table in power bi.
Thanks