Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more.
Get startedGrow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.
Hola
Necesito realizar esta nueva columna TipoProducto para lo que me pide y no se que función/funciones utilizar, gracias de antemano:
Tipo Producto. Almacenará el tipo de producto que se comercializa. Será Carne para aquellos productos cuyo Código Variedad comience por C, Pescado para aquellos productos cuyo Código Variedad comience por P y Frutas y Hortalizas para aquellos productos cuyo Código Variedad comience por F.
Solved! Go to Solution.
Puede hacerlo en DAX o power query. Prefiero Power Query.
DAX, puede hacerlo con "Switch" y "Contains", "ContainsString"
DAX - Agregar nueva columna:
Product Type Column =
var _pt_1stChar = LEFT('Table'[Variety Code], 1)
RETURN SWITCH(
TRUE(),
_pt_1stChar = "C", "Meat",
_pt_1stChar = "P", "Fish",
_pt_1stChar = "F", "Fruits & Vegetables"
)
DAX - Añadir nueva medida:
Product Type Measure =
var _pt_1stChar = LEFT(SELECTEDVALUE('Table'[Variety Code]), 1)
RETURN SWITCH(
TRUE(),
_pt_1stChar = "C", "Meat",
_pt_1stChar = "P", "Fish",
_pt_1stChar = "F", "Fruits & Vegetables"
)
Power query, puede hacerlo con "Text.StartsWith" o "Text.Contains" según sus necesidades y columna condicional:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wck4EA6VYnWilZAQzIB9JvCAfwXYrggEwN62oCEkgFgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Variety Code" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Variety Code", type text}}),
#"Added Conditional Column" = Table.AddColumn(#"Changed Type", "Product Type",
each if Text.StartsWith([Variety Code], "C", Comparer.OrdinalIgnoreCase) then "Meat"
else if Text.StartsWith([Variety Code], "P", Comparer.OrdinalIgnoreCase) then "Fish"
else if Text.StartsWith([Variety Code], "F", Comparer.OrdinalIgnoreCase) then "Fruits & Vegetables" else null)
in
#"Added Conditional Column"
No sé español, lo siento, usé un poco de texto para el código de Variety para obtener el código para ti.
Puede hacerlo en DAX o power query. Prefiero Power Query.
DAX, puede hacerlo con "Switch" y "Contains", "ContainsString"
DAX - Agregar nueva columna:
Product Type Column =
var _pt_1stChar = LEFT('Table'[Variety Code], 1)
RETURN SWITCH(
TRUE(),
_pt_1stChar = "C", "Meat",
_pt_1stChar = "P", "Fish",
_pt_1stChar = "F", "Fruits & Vegetables"
)
DAX - Añadir nueva medida:
Product Type Measure =
var _pt_1stChar = LEFT(SELECTEDVALUE('Table'[Variety Code]), 1)
RETURN SWITCH(
TRUE(),
_pt_1stChar = "C", "Meat",
_pt_1stChar = "P", "Fish",
_pt_1stChar = "F", "Fruits & Vegetables"
)
Power query, puede hacerlo con "Text.StartsWith" o "Text.Contains" según sus necesidades y columna condicional:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wck4EA6VYnWilZAQzIB9JvCAfwXYrggEwN62oCEkgFgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Variety Code" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Variety Code", type text}}),
#"Added Conditional Column" = Table.AddColumn(#"Changed Type", "Product Type",
each if Text.StartsWith([Variety Code], "C", Comparer.OrdinalIgnoreCase) then "Meat"
else if Text.StartsWith([Variety Code], "P", Comparer.OrdinalIgnoreCase) then "Fish"
else if Text.StartsWith([Variety Code], "F", Comparer.OrdinalIgnoreCase) then "Fruits & Vegetables" else null)
in
#"Added Conditional Column"
No sé español, lo siento, usé un poco de texto para el código de Variety para obtener el código para ti.
Una declaración switch debería hacerlo.
ProductType =
SWITCH(
TRUE(),
VarietyCode = "C", "Meat",
VarietyCode = "P", "Fish",
VarietyCode = "F", "Fruits & Vegetables"
)
Ask questions in Eventhouse and KQL, Eventstream, and Reflex.
Check out the May 2024 Power BI update to learn about new features.
User | Count |
---|---|
1 | |
1 | |
1 | |
1 | |
1 |