Forum Discussion
Creating a table with dynamic dates and one variable per date
- 5 years ago
Hi nlgenin
do you mean you want to create the table like bellow with M code?
Name Date A1 2021/1/1 A1 2021/1/2 A1 2021/1/3 A1 2021/1/4 A1 2021/1/5 A1 . A1 . A1 . A1 . A1 2021/6/23 A2 2021/1/1 A2 2021/1/2 A2 2021/1/3 A2 2021/1/4 A2 2021/1/5 A2 . A2 . A2 . A2 . A2 2021/6/23 -
here are my operations,
Then open the Advanced Editor, and paste the M code bellow into it
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcjRUitWhnDKimIoFAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Name = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Name", type text}}), #"Removed Duplicates" = Table.Distinct(#"Changed Type"), diffday=Int16.From( Date.From(DateTime.LocalNow()) - Date.From(#date(2021,1,1)))+1, #"Added Custom" = Table.AddColumn(#"Removed Duplicates", "Custom", each List.Dates(#date(2021, 1, 1), diffday, #duration(1, 0, 0, 0))), #"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom") in #"Expanded Custom"result:
See sample file attached bellow.
Best Regards,
Community Support Team _ Tang
If this post helps, please consider Accept it as the solution✔️ to help the other members find it more quickly.
nlgenin you can add a new column in PQ like this
{ [Min Date]..[Max Date] }
it will create a list and expand the list, you will get the all the dates for each tag.
Check my latest blog post Comparing Selected Client With Other Top N Clients | PeryTUS I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
⚡Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.⚡