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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Curious_Curious
Frequent Visitor

Creating a new column according to reference table

Hello,

 

I was wondering if someone would be able to help with something I am stuck on. I have the following table (ProductDate) with information in the format below:

 

Product numberDateDay of week
5JR3816 September 2022Friday
5JR3817 September 2022Saturday
5JR3818 September 2022Sunday
7QP1312 September 2022Monday
7QP1313 September 2022Tuesday
7QP1314 September 2022Wednesday
7QP1315 September 2022Thursday
7QP1316 September 2022Friday
7QP1317 September 2022Saturday
7QP1318 September 2022Sunday

 

I also have another table (ProductStock) with the number of stock available for a specific day of the week range:

 

Product NumberDay refStock
5JR38FriO20
5JR38WEnd65
7QP13MFriO7
7QP13MidWeek13
7QP13WEnd18

 

The Day ref column in the table above refers to a range of dates which are stored in a separate table (DayReference) as follows:

 

Day refMondayTuesdayWednesdayThursdayFridaySaturdaySunday
DailyYYYYYYY
FriONNNNYNN
WDYYYYYNN
MFriOYNNNYNN
WEndNNNNNYY
MidWeekNYYYNNN

 

The 'Day ref' column in the ProductStock table does not overlap (i.e. for a 'Product Number' there is no 'Day ref' which would refer to a day of the week twice).

 

What I am trying to do is create a new column using DAX in the first table (ProductDate) with the 'Day ref' populated from the ProductStock table only for the days of the week where there is 'Y' in the DayReference table. The expected result should be something like this:

 

Product numberDateDay of weekRelevant DayRef
5JR3816 September 2022FridayFriO
5JR3817 September 2022SaturdayWEnd
5JR3818 September 2022SundayWEnd
7QP1312 September 2022MondayMFriO
7QP1313 September 2022TuesdayMidWeek
7QP1314 September 2022WednesdayMidWeek
7QP1315 September 2022ThursdayMidWeek
7QP1316 September 2022FridayMFriO
7QP1317 September 2022SaturdayWEnd
7QP1318 September 2022SundayWEnd

 

Thank you

1 ACCEPTED SOLUTION
Syndicate_Admin
Administrator
Administrator

Hello, here you have two options:

1. Generate a DIM table (dimension) in which you bring a single value of the products (DISTINC function)
2. Generate a relationship "many to many" (this is the simplest but remember all relationship 'many to many' or "one to one" are weak and can bring several unwanted results)

Best regards

View solution in original post

3 REPLIES 3
Syndicate_Admin
Administrator
Administrator

Hello, here you have two options:

1. Generate a DIM table (dimension) in which you bring a single value of the products (DISTINC function)
2. Generate a relationship "many to many" (this is the simplest but remember all relationship 'many to many' or "one to one" are weak and can bring several unwanted results)

Best regards

Syndicate_Admin
Administrator
Administrator

Hello how are you?, I understand what you want to do, but the easiest way is simply to generate a relationship between these tabalas and you can create the table within the dashboard without problem

Thank you for your response. I was considering this but I am not really sure how to create a proper working relationship between those tables as the product number appears many times in the first two tables.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.