itsnotaboutthecell

Power Query M - Compatibility Table

Sep 14th, 2018
330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.47 KB | None | 0 0
  1. let
  2. Source = #table(
  3. type table [
  4. Text = text,
  5. Number = number,
  6. Logical = logical,
  7. Date = date,
  8. Time = time,
  9. DateTime = datetime,
  10. DateTimeZone = datetimezone,
  11. Duration = duration,
  12. Binary = binary,
  13. Null = any,
  14. List = list,
  15. Record = record,
  16. Table = table,
  17. Function = function,
  18. Type = type
  19. ],
  20. {
  21. {
  22. "Hello, World!", // Text
  23. 15.31, // Number
  24. false, // Logical
  25. #date(2018,9,14), // Date - (YYYY, MM, DD)
  26. #time(15,36,15), // Time - (HH, MM, SS)
  27. #datetime(2018,9,14,15,36,15), // DateTime - (YYYY, MM, DD, HH, MM, SS)
  28. #datetimezone(2018,9,14,15,36,15,-5,-30), // DateTimeZone - (YYYY, MM, DD, HH, MM, SS, Offset Hours, Offset Minutes)
  29. #duration(15,4,5,10), // Duration (D, H, M, S)
  30. #binary("0000"), // Binary
  31. null, // Null
  32. {1..100}, // List
  33. [a = 10, b = 30], // Record
  34. #table({"ID"},{{1}}), // table
  35. let foobar = (param) as any => foobar = param in foobar, // Function
  36. Value.Type(2) // Type
  37. }
  38. }
  39. ),
  40. #"Transposed Table" = Table.Transpose(Source, {"Values"}),
  41. #"Custom Types" = Table.AddColumn(#"Transposed Table", "Type", each Value.Type([Values])),
  42. #"Compatability: Text" = Table.AddColumn(#"Custom Types", "Text", each [Values] & " Hello Steve!", type text),
  43. #"Compatability: Number" = Table.AddColumn(#"Compatability: Text", "Number", each [Values] + 45, type number),
  44. #"Compatability: Logical" = Table.AddColumn(#"Compatability: Number", "Logical", each false = [Values], type logical),
  45. #"Compatability: Date" = Table.AddColumn(#"Compatability: Logical", "Date", each #date(2022,10,31) - [Values], type date),
  46. #"Compatability: Time" = Table.AddColumn(#"Compatability: Date", "Time", each #time(16,52,30) - [Values], type time),
  47. #"Compatability: Date Time" = Table.AddColumn(#"Compatability: Time", "Date Time", each #datetime(2023,8,5,18,24,15) - [Values], type datetime),
  48. #"Compatability: Date Time Zone" = Table.AddColumn(#"Compatability: Date Time", "Date Time Zone", each #datetimezone(2024,7,15,19,56,12,-4,-15) - [Values], type datetimezone),
  49. #"Compatability: Duration" = Table.AddColumn(#"Compatability: Date Time Zone", "Duration", each #duration(20,15,45,32) + [Values], type duration),
  50. #"Compatability: Binary" = Table.AddColumn(#"Compatability: Duration", "Binary", each #binary({0x03, 0x01}) & [Values], type binary),
  51. #"Compatability: Null" = Table.AddColumn(#"Compatability: Binary", "Null", each null & [Values], type null),
  52. #"Compatability: List" = Table.AddColumn(#"Compatability: Null", "List", each {1..5} & [Values], type list),
  53. #"Compatability: Record" = Table.AddColumn(#"Compatability: List", "Record", each [d = 45, z = 105] & [Values], type record),
  54. #"Compatability: Table" = Table.AddColumn(#"Compatability: Record", "Table", each #table({"ID"}, {{25}}) & [Values], type table),
  55. #"Compatability: Function" = Table.AddColumn(#"Compatability: Table", "Function", each () => let returnVal = [Values] in returnVal, type function),
  56. #"Compatability: Type" = Table.AddColumn(#"Compatability: Function", "Type.1", each Value.Type("Hello, World!") & [Values], type type),
  57. #"Replaced Errors" = Table.ReplaceErrorValues(#"Compatability: Type", {
  58. {"Text", null},
  59. {"Number", null},
  60. {"Logical", null},
  61. {"Date", null},
  62. {"Time", null},
  63. {"Date Time", null},
  64. {"Date Time Zone", null},
  65. {"Duration", null},
  66. {"Binary", null},
  67. {"Null", null},
  68. {"List", null},
  69. {"Record", null},
  70. {"Table", null},
  71. {"Function", null},
  72. {"Type.1", null}
  73. }
  74. )
  75. in
  76. #"Replaced Errors"
Advertisement
Add Comment
Please, Sign In to add comment