Forum Discussion
ClaudioF
Helper II
1 year agocombinatorics in dinamic dax
Hello guys, i have posted here so many times about getting a logic right, but i just noticed it was impossible, in the way i was thinking, no one could help me. I have a new aproach of how to get th...
- 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
VahidDM
Super User
1 year agoYou 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],
"; "
)
ClaudioF
Helper II
1 year agodidnt 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!!