Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
TonyHollywood
New Member

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.

1 ACCEPTED SOLUTION

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...

View solution in original post

6 REPLIES 6
m_dekorte
Super User
Super User

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

  • 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?

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

Thanks again m_dekorte, really appreciate your help. At least I know now I am not going mad. 

I am using the datetime as I want to generate a key that is unlikely to be replicated.  Any suggestions as to how I can generate something unique out a function that will remain 'static' ?

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...

Many thanks for your help m_dekorte.

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors