Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hello,
I'm trying to add a date column to the dataset(the expected ouput given below).
Can you help me with the DAX expression to acheive the re
Id | Amount | DateA | DateB |
298704 | 65516 | 10-03-2020 | 20-02-2020 |
298705 | 26206.4 | 16-04-2020 | 01-04-2020 |
298706 | 27005.4 | 12-05-2020 | 23-04-2020 |
298707 | 67513.5 | 01-04-2020 | 17-03-2020 |
O/P Table:
Date Main | Id | Amount | DateA | DateB |
01-01-2020 | 298704 | 65516 | 10-03-2020 | 20-02-2020 |
01-01-2020 | 298705 | 26206.4 | 16-04-2020 | 01-04-2020 |
01-01-2020 | 298706 | 27005.4 | 12-05-2020 | 23-04-2020 |
01-01-2020 | 298707 | 67513.5 | 01-04-2020 | 17-03-2020 |
02-01-2020 | 298704 | 65516 | 10-03-2020 | 20-02-2020 |
02-01-2020 | 298705 | 26206.4 | 16-04-2020 | 01-04-2020 |
02-01-2020 | 298706 | 27005.4 | 12-05-2020 | 23-04-2020 |
02-01-2020 | 298707 | 67513.5 | 01-04-2020 | 17-03-2020 |
03-01-2020 | 298704 | 65516 | 10-03-2020 | 20-02-2020 |
03-01-2020 | 298705 | 26206.4 | 16-04-2020 | 01-04-2020 |
03-01-2020 | 298706 | 27005.4 | 12-05-2020 | 23-04-2020 |
03-01-2020 | 298707 | 67513.5 | 01-04-2020 | 17-03-2020 |
Solved! Go to Solution.
not sure I understand correct what do you need, but maybe create new CROSSJOIN() table will help you:
New Table = CROSSJOIN('Table', CALENDAR(DATE(2020,1,1), DATE(2020,12,31)))
Hi @kkalyanrr
If you've fixed the issue on your own please kindly share your solution. if the above posts help, please kindly mark it as a solution to help others find it more quickly. If not, please kindly elaborate more. thanks!
@kkalyanrr , refer if this file can help. This has an example to create dates between two dates. The file is attached after signature
If you have additional transformations to do after this step, you can also do this cross join in the query editor. Please see the M code below that does so with your example data. Just create a blank query, go to Advanced Editor, and replace the code there with this.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("ZY5BCsAwCAT/knMMq4navqXk/99oJK1QepKR2WWvq8h5OEapxVTZ1mUQOgkEC2SBbJj1kTX+JrAWMTbCeHVwQurRKQ7o1oWg2d7/uscUV+5Nv4Ur67lszhs=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Id = _t, Amount = _t, DateA = _t, DateB = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Id", Int64.Type}, {"Amount", type number}, {"DateA", type text}, {"DateB", type text}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Date Main", each List.Dates(#date(2020,1,1), 366, #duration(1,0,0,0))),
#"Expanded Date Main" = Table.ExpandListColumn(#"Added Custom", "Date Main"),
#"Changed Type1" = Table.TransformColumnTypes(#"Expanded Date Main",{{"Date Main", type date}})
in
#"Changed Type1"
If this works for you, please mark it as the solution. Kudos are appreciated too. Please let me know if not.
Regards,
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
whats rule to define your new date column?
not sure I understand correct what do you need, but maybe create new CROSSJOIN() table will help you:
New Table = CROSSJOIN('Table', CALENDAR(DATE(2020,1,1), DATE(2020,12,31)))
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
112 | |
100 | |
80 | |
64 | |
57 |
User | Count |
---|---|
145 | |
111 | |
92 | |
84 | |
66 |