hworrall
Hola,
Soy nuevo en Power BI y estoy tratando de escribir una consulta en la que necesito restar el resultado de una consulta del resultado de una segunda consulta. Esto es lo que tengo en SQL / Inglés. También hay dos columnas de fecha diferentes, no es un error tipográfico. No estoy seguro de cómo hacerlo, pero también me gustaría encontrar la forma más eficiente de hacerlo.
Se agradece cualquier ayuda 🙂
Consulta 1:
Suma TotalCharge donde:
SELECCIONE Wdate, Wpdate, Whours, Wfee, Wexp, wFee + wExp + wSurchg como TotalCharge, Wdstamp, Wipdate, Windicator
DESDE WIP
DONDE Wdate <'2018-05-01' Y Wipdate> ‘2018-04-30’ Y (Windicator = «w» o Windicator = «h»)
MENOS
Consulta 2:
Suma TotalCharge donde:
SELECCIONE Wdate, Wpdate, Whours, Wfee, Wexp, wFee + wExp + wSurchg como TotalCharge, Wdstamp, Wipdate, Windicator
DESDE WIP
DONDE Wdate> ‘2018-04-30’ Y Wipdate <'2018-05-01' Y (Windicator = "w" o Windicator = "h")
¡Gracias!
ImkeF
Hola @hworrall,
pegue este código en el editor avanzado y siga los pasos:
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjDUAyIjA0MLJR0wxxzGKQdiQwOlWB18ijKA2IiQokQgNkZTZInNOhNirDMlxjozNEXmUEVwDsg6c6CiWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Wdate = _t, Wipdate = _t, Windicator = _t, TotalCharge = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Wdate", type date}, {"Wipdate", type date}, {"Windicator", type text}, {"TotalCharge", Int64.Type}}), Filter1 = Table.SelectRows(#"Changed Type", each [Wdate] < #date(2019, 5, 1) and [Wipdate] > #date(2018, 4, 30) and ( [Windicator] = "w" or [Windicator] = "h" ) ), Query1 = List.Sum(Filter1[TotalCharge]), Filter2 = Table.SelectRows(#"Changed Type", each [Wdate] > #date(2018, 4, 30) and [Wipdate] < #date(2019, 5, 1) and ( [Windicator] = "w" or [Windicator] = "h" ) ), Query2 = List.Sum(Filter2[TotalCharge]), Result = Query1 + Query2 in Result