Forum Discussion
Measure to add two values from two different columns that meet a condition.
- 1 year ago
hello telesforo1969
in addition of ryan_mayu 's solution, you can use DAX.
Sum =
var _Tipo = SELECTEDVALUE('Table'[Tipo1])
Return
SUM('Table'[Costo1])
+
CALCULATE(
SUM('Table'[Costo2]),
FILTER(
ALL('Table'),
'Table'[Tipo2]=_Tipo
)
)you can choose which way that suit your preferences.Hope this will help.Thank you.
you can try this in PQ
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUXICYkMDMGGgFKsTDRYASRiBBE2hgs5QQWOQoBlIMBYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Tipo1 = _t, Tipo2 = _t, #"Costo 1" = _t, #"Costo 2" = _t]),
Custom1 = Table.SelectColumns(Source, {"Tipo1", "Costo 1"}),
tb1 = Table.RenameColumns(Custom1,{{"Tipo1", "Tipo"}, {"Costo 1", "Costo"}}),
Custom2 = Table.SelectColumns(Source, {"Tipo2", "Costo 2"}),
tb2 = Table.RenameColumns(Custom2,{{"Tipo2", "Tipo"}, {"Costo 2", "Costo"}}),
Custom3 = Table.Combine({ tb1, tb2}),
#"Changed Type" = Table.TransformColumnTypes(Custom3,{{"Costo", Int64.Type}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"Tipo"}, {{"costo", each List.Sum([Costo]), type nullable text}})
in
#"Grouped Rows"
pls see the attahment below
- telesforo19691 year ago
Helper V
I'll implement your solution and let you know. Thank you very much for now.