Forum Discussion
Key
Hi Community
I want to create a unique key that I can then join to another table with multiple rows. The purpose being that I can then recover the rows in the second table based on the key in the first table. I tried using the DateTime.FixedLocalNow() as part of the key but after joining to the second table the time is slightly different from the time in the created key and does not match. Any suggestions as to how to create the key.
I think you might be are out of luck there, M functions "update" when evaluated. If you need a "static" value that will have to be provided by a datasource. For example, the date/time a file or an export was created and so on.
Depending on your scenario and its complexity, you could generate a list or column of values (indices) from which you take the first "free" number...
6 Replies
- m_dekorteResident Rockstar
Hi TonyHollywood,
Create an separate query to hold the DateTime.FixedLocalNow() value
You can refer to that query by name when generating keys in both tables
I hope this is helpful
- TonyHollywoodNew Member
- Hi m_dekorte thank you for your speedy reply. I have tried this but, unless I am doing something wrong each time I reference the separate query it comes back with an updated time. Any suggestions?
- m_dekorteResident Rockstar
Hi TonyHollywood ,
You are right. Don't know why you want to include time in your key but maybe consider:
1. Lowering the granularity, how about stripping off seconds?
DateTime.ToText( DateTime.FixedLocalNow(), [Format= "dd-MM-yyyy hh:mm"])
2. Round time for exampl up to quarters:
DateTime.From( Number.RoundUp( Number.From(DateTime.FixedLocalNow()) * ((24*60)/15), 0)/ ((24*60)/15))
3. Or setting an arbitrary time value
I hope this is helpful