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.
Olá,
Vendo produto por unidade e por kit (componentes). Mas quero saber qual foi o total vendido por unidade.
Na imagem foi vendido:
4 camisas,
5 kits contendo 3 camisas
3 kits contento 2 camisas e 1 bermuda.
Quero calcular o total de camisas:
Total de camisas = 4 + (5 * 3) + (3 * 2)
Total de camisas= 4 + 15 + 6
Total de camisas= 25
PBIX aqui
Solved! Go to Solution.
You don't need measures for this. A calculated column in the fVenda table is enough
Total Qty =
var parentCode=LOOKUPVALUE(fComponentes[CodProduto],fComponentes[CodProduto],[CodProduto])
var subqty = COALESCE(CALCULATE(sum(fComponentes[Qtde_componente]),fComponentes[CodProduto]=parentCode),1)
return subqty*[Qtde_vendida]
Hi @Vilmar ,
Generally, I don't create any relationship in this case.
Here's my solution.
1.Create a measure to get the Venda in table 'fComponentes'.
VendaInfComponentes =
CALCULATE (
SUM ( fVenda[Qtde_vendida] ),
FILTER ( 'fVenda', [CodProduto] = MAX ( 'fComponentes'[CodProduto] ) )
)
2.Create a measure to get the product.
Sum =
[VendaInfComponentes] * SUM ( 'fComponentes'[Qtde_componente] )
3.Create a measure to get the Venda in table 'dProduto'.
VendaIndProduto =
CALCULATE (
SUM ( fVenda[Qtde_vendida] ),
FILTER ( 'fVenda', [CodProduto] = MAX ( 'dProduto'[CodProduto] ) )
)
4.Create a measure to call the [SUM] meausre in table 'fComponentes' into table 'dProduto'.
Sum2 =
SUMX (
FILTER (
ALLSELECTED ( 'fComponentes' ),
[Cod_Componente] = MAX ( 'dProduto'[CodProduto] )
),
[Sum]
)
5.Now you can add them up to get the total.
Total Venda = [Sum2]+[VendaIndProduto]
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Vilmar ,
Generally, I don't create any relationship in this case.
Here's my solution.
1.Create a measure to get the Venda in table 'fComponentes'.
VendaInfComponentes =
CALCULATE (
SUM ( fVenda[Qtde_vendida] ),
FILTER ( 'fVenda', [CodProduto] = MAX ( 'fComponentes'[CodProduto] ) )
)
2.Create a measure to get the product.
Sum =
[VendaInfComponentes] * SUM ( 'fComponentes'[Qtde_componente] )
3.Create a measure to get the Venda in table 'dProduto'.
VendaIndProduto =
CALCULATE (
SUM ( fVenda[Qtde_vendida] ),
FILTER ( 'fVenda', [CodProduto] = MAX ( 'dProduto'[CodProduto] ) )
)
4.Create a measure to call the [SUM] meausre in table 'fComponentes' into table 'dProduto'.
Sum2 =
SUMX (
FILTER (
ALLSELECTED ( 'fComponentes' ),
[Cod_Componente] = MAX ( 'dProduto'[CodProduto] )
),
[Sum]
)
5.Now you can add them up to get the total.
Total Venda = [Sum2]+[VendaIndProduto]
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
You don't need measures for this. A calculated column in the fVenda table is enough
Total Qty =
var parentCode=LOOKUPVALUE(fComponentes[CodProduto],fComponentes[CodProduto],[CodProduto])
var subqty = COALESCE(CALCULATE(sum(fComponentes[Qtde_componente]),fComponentes[CodProduto]=parentCode),1)
return subqty*[Qtde_vendida]
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 |
---|---|
97 | |
96 | |
81 | |
74 | |
66 |
User | Count |
---|---|
129 | |
106 | |
106 | |
86 | |
72 |