我有下表,希望能够通过链接键将当前日期与旧日期进行比较。
链接键 | 类别 | 日期 |
---|---|---|
111 | 当前 | 23 年 4 月 12 日 |
111 | 旧 | 23 年 4 月 15 日 |
333 | 当前 | 23 年 4 月 15 日 |
333 | 旧 | 23 年 4 月 16 日 |
一旦将旧日期作为计算列,我就知道如何计算日期差异,但如何将其变为下面的形状?我知道我必须使用链接密钥,但不确定如何使用。我无法旋转表格,因为它还用于其他视觉效果。
链接键 | 类别 | 日期 | 旧日期 |
---|---|---|---|
111 | 当前 | 23 年 4 月 12 日 | 23 年 4 月 15 日 |
111 | 旧 | 23 年 4 月 15 日 | 23 年 4 月 15 日 |
333 | 当前 | 23 年 4 月 15 日 | 23 年 4 月 16 日 |
333 | 旧 | 23 年 4 月 16 日 | 23 年 4 月 16 日 |
然后我会在视觉效果中过滤当前类别,以便不存在重复项。
您可以在 Power Query 中使用 M 语言创建超前/滞后列
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjRSitWJVjI2BVNGxmDKxBxMmZqBKXMLMGUBUWJpqBQbCwA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Number = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Number", Int64.Type}}),
#"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 0, 1, Int64.Type),
#"xyz" = Table.AddColumn(#"Added Index", "Lead", each #"Added Index"{[Index]+1}[#"Number"]),
#"Replaced Errors" = Table.ReplaceErrorValues(xyz, {{"Index", 0}}),
#"Replaced Errors1" = Table.ReplaceErrorValues(#"Replaced Errors", {{"Lead", 0}}),
#"abc" = Table.AddColumn(#"Replaced Errors1", "Lag", each #"Added Index"{[Index]-1}[#"Number"]),
#"Replaced Errors2" = Table.ReplaceErrorValues(abc, {{"Lag", 0}})
in
#"Replaced Errors2"