Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
Hello,
I tried to find an answer but was not able to find anything.
English is a second language sorry if I'm unclear.
In PowerQuery, I'm trying to automatically categorize products based on their category and net weight.
Here is an example of the final result I'm trying to achieve :
SKU | Niv1 | Niv2 | Niv3 | Net Weight | Size |
12 | Food | Cat | Dry | 2.5 | Small |
13 | Food | Cat | Dry | 7 | Large |
14 | Food | Dog | Dry | 7 | Medium |
15 | Food | Dog | Dry | 15 | Large |
Cat between 0 and 3 kg, it's a small bag, 3 and 8 it's a large bag.
But in the dog food i.e. 7kg is considered a medium bag.
I'm directly logged in to a material table in SAP via an OData link, but that information is not managed or maintained in SAP.
I initially tried to map every actual available size for each segment but as we create new SKUs, new weights are available so I would rather use a range logic.
Please let me know if there's any more information I can provide.
Thanks for the support
Best!
Solved! Go to Solution.
You can create a table with the parameters and a custom column to calculate it.
let
_cat = [Niv2],
_weight = [Net Weight]
in
List.First(Table.SelectRows(TB_PARAMETERS,
each
[Niv2] = _cat and
[Max] >= _weight)[Label])
Hi @alexproulx ,
You can create a column like this:
Size =
SWITCH (
[Niv2],
"Cat",
SWITCH (
TRUE (),
[Net Weight] >= 0
&& [Net Weight] <= 3, "Small",
[Net Weight] > 3
&& [Net Weight] <= 8, "Large"
),
"Dog",
SWITCH (
TRUE (),
[Net Weight] >= 0
&& [Net Weight] <= 3, "Small",
[Net Weight] > 3
&& [Net Weight] <= 7, "Medium",
[Net Weight] > 7, "Large"
)
)
Attached a sample file in the below, hopes to help you.
Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
You can create a table with the parameters and a custom column to calculate it.
let
_cat = [Niv2],
_weight = [Net Weight]
in
List.First(Table.SelectRows(TB_PARAMETERS,
each
[Niv2] = _cat and
[Max] >= _weight)[Label])