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

60 Days of Data Days! Live and on-demand sessions, challenges, study groups and more! And it's all FREE!. Join now. Learn more

Reply
Stinkys
Advocate II
Advocate II

Creating Composite Primary Key

Hi all,

 

I am trying to understand the best method for creating a composite primary key where one of the columns is a date. I have several columns that when combined create my unique record - int, text, date. In lakehouse my date is stored in yyyy-mm-dd however when working with Text.Combine in Dataflow Gen2 it outputs as dd/mm/yyyy.

 

Anyone have a guide on how to best implement a composite key that will respect the original database date format so that my composite key will be along the lines of "6789-ABC123-2024-11-05"? I feel like PySpark might be the best answer here in generating keys prior to or after the DFG2 process.

1 ACCEPTED SOLUTION
FabianSchut
Solution Sage
Solution Sage

Hi, in DataFlow Gen2, you first need to convert the date format to a string format where you have defined the string format yourself. An example of a query will look like this:

Table.TransformColumns(#"Changed column type", {{"Column1", each Date.ToText(Date.From(_),"yyyy-MM-dd"), type text}})

If you want to achieve this with Python use something like

.strftime('%Y-%m-%d')

View solution in original post

2 REPLIES 2
Stinkys
Advocate II
Advocate II

Thanks for the reply Fabian. I was hoping there was a cleaner method for this, as it seems counter-intuitive to go from db date (db) to formatted date (dfg2 initial load) to db date (for merge) then back to clean formatted date for data warehouse. Would be nice if I could work with that raw db date value in dfg2.

FabianSchut
Solution Sage
Solution Sage

Hi, in DataFlow Gen2, you first need to convert the date format to a string format where you have defined the string format yourself. An example of a query will look like this:

Table.TransformColumns(#"Changed column type", {{"Column1", each Date.ToText(Date.From(_),"yyyy-MM-dd"), type text}})

If you want to achieve this with Python use something like

.strftime('%Y-%m-%d')

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

June Fabric Update Carousel

Fabric Monthly Update - June 2026

Check out the June 2026 Fabric update to learn about new features.

Top Solution Authors