Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
I need to calculate the percentage of calculated column B, based on column A +B. I have two calculated columns, each one for a customer segment.
A - Column Retention = Customers that had their first purchase before 2021
Formula:
Vendas clientes Retenção < 2021 =
VAR m = 'Base Clientes e Pedidos'[Data_primeiro_pedido]
RETURN
CALCULATE(DISTINCTCOUNT('Base Clientes e Pedidos'[id_pedido_promob]),
FILTER('Base Clientes e Pedidos', m <= DATE(2021,01,01)))
B - Column New Clientes = Customers that had their first purchase after 2021
Formula:
Vendas clientes novos >2021 =
VAR m = 'Base Clientes e Pedidos'[Data_primeiro_pedido]
RETURN
CALCULATE(DISTINCTCOUNT('Base Clientes e Pedidos'[id_pedido_promob]),
FILTER('Base Clientes e Pedidos', m >= DATE(2021,01,01)))
I'm having a hard time to calculate the percentage % of new clients based on the calculated columns.
What i need: B/(A+B)
I've tried:
% Venda para Novos =
VAR m = 'Base Clientes e Pedidos'[Data_primeiro_pedido]
RETURN
DIVIDE(CALCULATE(DISTINCTCOUNT('Base Clientes e Pedidos'[id_pedido_promob]),
FILTER('Base Clientes e Pedidos', m >= DATE(2021,01,01)
)
), DISTINCTCOUNT('Base Clientes e Pedidos'[id_pedido_promob])
)
But it doesn't work as expected, returning the value of column B instead of B/(A+B)
Solved! Go to Solution.
Do you really create two calculated columns or measures?
You can try this:
MEASURE =
VAR m = 'Base Clientes e Pedidos'[Data_primeiro_pedido]
VAR _2021 =
CALCULATE(DISTINCTCOUNT('Base Clientes e Pedidos'[id_pedido_promob]),
FILTER('Base Clientes e Pedidos', m <= DATE(2021,01,01)))
VAR _2022 =
RETURN
_2021/(_2021+_2022)
If it not work. Please post your underlaying data structure and where do you want to use this measure.
AND be aware of <= and >=. In This case you will count rows with 2021-01-01 twice!
Proud to be a Super User!
I've tried both solutions, but it doesn't allow me to filter data to each Sales Person
As follow:
Change ...
FILTER(ALL('Base Clientes e Pedidos'), 'Base Clientes e Pedidos'[Data_primeiro_pedido]
To...
FILTER(ALL('Base Clientes e Pedidos'[Data_primeiro_pedido]), 'Base Clientes e Pedidos'[Data_primeiro_pedido]
Try the following...
% Venda para Novos =
VAR B = CALCULATE(DISTINCTCOUNT('Base Clientes e Pedidos'[id_pedido_promob]),
FILTER(ALL('Base Clientes e Pedidos'), 'Base Clientes e Pedidos'[Data_primeiro_pedido] >= DATE(2021,01,01)))
VAR A = CALCULATE(DISTINCTCOUNT('Base Clientes e Pedidos'[id_pedido_promob]),
FILTER(ALL('Base Clientes e Pedidos'), 'Base Clientes e Pedidos'[Data_primeiro_pedido] < DATE(2021,01,01)))
RETURN DIVIDE(B,A+B,0)
Do you really create two calculated columns or measures?
You can try this:
MEASURE =
VAR m = 'Base Clientes e Pedidos'[Data_primeiro_pedido]
VAR _2021 =
CALCULATE(DISTINCTCOUNT('Base Clientes e Pedidos'[id_pedido_promob]),
FILTER('Base Clientes e Pedidos', m <= DATE(2021,01,01)))
VAR _2022 =
RETURN
_2021/(_2021+_2022)
If it not work. Please post your underlaying data structure and where do you want to use this measure.
AND be aware of <= and >=. In This case you will count rows with 2021-01-01 twice!
Proud to be a Super User!
Hello, i've created calculated columns, thats why i could calculate each row. Changin it to measure and it worked!
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
43 | |
23 | |
21 | |
15 | |
15 |
User | Count |
---|---|
45 | |
31 | |
30 | |
18 | |
17 |