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
Stabben23
Helper I
Helper I

Add shift to fact table

Hi guys,

 

I want to add shift to my fact table, I have a dimension with start and end timestamp and a fact with timestamp.

Now I want to map the shift field into facttable. 

All solutions is OK, connections between tables or dax formulas. What I want to achieve is that I can use shift with visualizations.

My Timestamp in fact is connected to a calendartable. Expected is my mapped field.

shift.PNG

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

In Table1, write this calculated column formula

=LOOKUPVALUE(Table2[Shift],Table2[DateStart],CALCULATE(MIN(Table2[Datastart]),FILTER(Table2,Table2[DateStart]<=EARLIER(Table1[TimeStamp])&&Table2[DateEnd]>=EARLIER(Table1[TimeStamp]))))

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

4 REPLIES 4
Stabben23
Helper I
Helper I

Thanks to all,

Great to see how other solve this common issue in Power BI.

I like the lookupvalue solution best and this was pretty near what I have play around with.

Ashish_Mathur
Super User
Super User

Hi,

In Table1, write this calculated column formula

=LOOKUPVALUE(Table2[Shift],Table2[DateStart],CALCULATE(MIN(Table2[Datastart]),FILTER(Table2,Table2[DateStart]<=EARLIER(Table1[TimeStamp])&&Table2[DateEnd]>=EARLIER(Table1[TimeStamp]))))

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
az38
Community Champion
Community Champion

Hi @Stabben23 

 

Try new measure to the FactTable

Expected = CALCULATE(max(dimTable[Shift]);filter(all(dimTable);and(dimTable[DateStart]<=SELECTEDVALUE(FactTable[TimeStamp]);dimTable[DateEnd]>SELECTEDVALUE(FactTable[TimeStamp]))))
 

 


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn
mwegener
Most Valuable Professional
Most Valuable Professional

Hi @Stabben23 ,

 

look at this.

https://community.powerbi.com/t5/Desktop/Join-with-greater-than-AND-less-than-to-join-date-time-tabl...

 

If I answered your question, please mark my post as solution, this will also help others.

Please give Kudos for support.

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials


Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors