Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
Hello
I'd like to subtract other figures from the total figure. then I'd like to replace the total value with the new value. how can I do this in Power Query?
Solved! Go to Solution.
Design red flag. Do not repeat data in the same table.
let
Source = Table.FromRows(
Json.Document(
Binary.Decompress(
Binary.FromText(
"i45WCskvScxR0oHThgYGSrE60UoBiUWZxUC+c2ZJJZAyBQv65Oel5OehiMYCAA==",
BinaryEncoding.Base64
),
Compression.Deflate
)
),
let
_t = ((type nullable text) meta [Serialized.Text = true])
in
type table [Column1 = _t, Column2 = _t, Column3 = _t]
),
#"Changed Type" = Table.TransformColumnTypes(
Source,
{{"Column1", type text}, {"Column2", type text}, {"Column3", Int64.Type}}
),
#"Replaced Value" = Table.ReplaceValue(
#"Changed Type",
each [Column3],
each
if [Column2] = "Total" then
[Column3] - List.Sum(List.Skip(#"Changed Type"[Column3], 1))
else
[Column3],
Replacer.ReplaceValue,
{"Column3"}
)
in
#"Replaced Value"
How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done". Once you examined the code, replace the Source step with your own source.
thank you.. Its work! 🙏
Design red flag. Do not repeat data in the same table.
let
Source = Table.FromRows(
Json.Document(
Binary.Decompress(
Binary.FromText(
"i45WCskvScxR0oHThgYGSrE60UoBiUWZxUC+c2ZJJZAyBQv65Oel5OehiMYCAA==",
BinaryEncoding.Base64
),
Compression.Deflate
)
),
let
_t = ((type nullable text) meta [Serialized.Text = true])
in
type table [Column1 = _t, Column2 = _t, Column3 = _t]
),
#"Changed Type" = Table.TransformColumnTypes(
Source,
{{"Column1", type text}, {"Column2", type text}, {"Column3", Int64.Type}}
),
#"Replaced Value" = Table.ReplaceValue(
#"Changed Type",
each [Column3],
each
if [Column2] = "Total" then
[Column3] - List.Sum(List.Skip(#"Changed Type"[Column3], 1))
else
[Column3],
Replacer.ReplaceValue,
{"Column3"}
)
in
#"Replaced Value"
How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done". Once you examined the code, replace the Source step with your own source.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 6 | |
| 3 | |
| 3 | |
| 3 | |
| 2 |