Forum Discussion
combinatorics in dinamic dax
- 1 year ago
didnt work.. i think its not even possible though, i am thinking about changing to python completlty in order to achieve this result i need
Hey there! thankyou for your return;
This code you provided is generating an error: The GENERATE function does not allow two columns with the same name "DB_ORDERS"[Cliente]. i got this same problem in other attempts..
You right 🙂
Try this:
BestCombination =
VAR CurrentProduct = SELECTEDVALUE('DB_ORDERS'[Produto])
VAR OrdersTable =
FILTER(
ALL('DB_ORDERS'),
'DB_ORDERS'[Produto] = CurrentProduct
)
VAR OrdersDistinct =
SELECTCOLUMNS(
OrdersTable,
"Pedido", 'DB_ORDERS'[Pedido],
"QT_falt", 'DB_ORDERS'[QT. falt]
)
VAR Combos =
GENERATE(
OrdersDistinct,
FILTER(
OrdersDistinct,
[Pedido] <= EARLIER([Pedido])
)
)
VAR ComboSummary =
ADDCOLUMNS(
Combos,
"PedidosConcatenados",
CONCATENATEX(
FILTER(OrdersDistinct, [Pedido] <= EARLIER([Pedido])),
[Pedido],
", ",
[Pedido], ASC
),
"Soma_Quant_Falta",
SUMX(
FILTER(OrdersDistinct, [Pedido] <= EARLIER([Pedido])),
[QT_falt]
),
"Qtd_Pedidos",
COUNTROWS(
FILTER(OrdersDistinct, [Pedido] <= EARLIER([Pedido]))
)
)
VAR FilteredCombos =
FILTER(
ComboSummary,
[Soma_Quant_Falta] <= 21
)
VAR MaxQtdPedidos =
MAXX(FilteredCombos, [Qtd_Pedidos])
VAR BestCombo =
TOPN(
1,
FILTER(FilteredCombos, [Qtd_Pedidos] = MaxQtdPedidos),
[Soma_Quant_Falta], DESC
)
RETURN
CONCATENATEX(
BestCombo,
[PedidosConcatenados],
"; "
)
- ClaudioF1 year ago
Helper II
didnt work.. i think its not even possible though, i am thinking about changing to python completlty in order to achieve this result i need
- v-sathmakuri1 year ago
Community Support
Hi ClaudioF ,
Thank you for reaching out to Microsoft Fabric Community. Sorry for the delay in response.
Thank you VahidDM for the prompt response.
May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.
Thank you!!