The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
I want to calculate the dax for below table
This need to calculate based on date and name.
Same date and same name means first value should be sum other will be blank
Solved! Go to Solution.
Here is my solution with Power Query. Hope it helps.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMtY31Dc2UNJRcgRip6LUxGwgbWigFKuDW9oIv7QxprQTfsORpU0JycYCAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Name = _t, Activity = _t, Time = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Name", type text}, {"Activity", type text}, {"Time", Int64.Type}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"Date", "Name"}, {{"All Rows", each Table.AddIndexColumn(_, "Index", 1, 1), type table}, {"Total", each List.Sum([Time]), type nullable number}}),
#"Removed Other Columns" = Table.SelectColumns(#"Grouped Rows",{"All Rows", "Total"}),
#"Expanded All Rows" = Table.ExpandTableColumn(#"Removed Other Columns", "All Rows", {"Date", "Name", "Activity", "Time", "Index"}, {"Date", "Name", "Activity", "Time", "Index"}),
#"Replaced Value" = Table.ReplaceValue(#"Expanded All Rows", each if [Index] <> 1 then [Total] else false, each 0, Replacer.ReplaceValue, {"Total"})
in
#"Replaced Value"
Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.
Anything is fine. Please help me
Here is my solution with Power Query. Hope it helps.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMtY31Dc2UNJRcgRip6LUxGwgbWigFKuDW9oIv7QxprQTfsORpU0JycYCAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Name = _t, Activity = _t, Time = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Name", type text}, {"Activity", type text}, {"Time", Int64.Type}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"Date", "Name"}, {{"All Rows", each Table.AddIndexColumn(_, "Index", 1, 1), type table}, {"Total", each List.Sum([Time]), type nullable number}}),
#"Removed Other Columns" = Table.SelectColumns(#"Grouped Rows",{"All Rows", "Total"}),
#"Expanded All Rows" = Table.ExpandTableColumn(#"Removed Other Columns", "All Rows", {"Date", "Name", "Activity", "Time", "Index"}, {"Date", "Name", "Activity", "Time", "Index"}),
#"Replaced Value" = Table.ReplaceValue(#"Expanded All Rows", each if [Index] <> 1 then [Total] else false, each 0, Replacer.ReplaceValue, {"Total"})
in
#"Replaced Value"
Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.
Does it have to be DAX? Would be much simpler in Power Query.
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the August 2024 Power BI update to learn about new features.