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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
rishirajdeb
Advocate I
Advocate I

Data modeling with discrete dimension table

Hello All,

I have a problem in hand and would appreciate if someone can help me out...

Let me explain the scenario =>

Fact table:

rishirajdeb_0-1623147495715.png

Dimension table:

rishirajdeb_1-1623147518917.png

Now the problem with this dimension table is that it does not contain records for each month (that’s how it is modelled at back-end). It needs to be read like this –

  1. For product# 123, the value is 5 for Jan-20 as well as Feb-20. For Mar-20 onwards the new value should be 6
  2. For product# 456, the value from Jan-20 onwards is 7 (until a new value is maintained in future)

& so on….

Hence, if I need to compute the amount (value*unit) in the fact table – It should look like this:

rishirajdeb_2-1623147594492.png

It cannot be done by creating a composite key combining ‘date’ & ‘product#’ and relating both the tables,  as all the keys would not exist in the dimension table (amounts in red would be blank then).

Any idea how to achieve this? or the best possible options I have for this scenario?

(Of course, the data here is representative – the actual tables have huge data (in millions) & hence the solution needs to be dynamic)

Please stay safe!

 

Regards,

Rishi

 

@GilbertQ  @collinq  @ibarrau 

@v-luwang-msft  @v-xuding-msft 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@rishirajdeb , Assume you have date or create a date from month year

date = "01-" & [Month year] //change data type to date


New column in Fact =

var _dt = maxx(filter(dim, dim[product#] =fact[product#] && dim[Date]<=fact[Date]),Dim[Date])
return
fact[amount]* maxx(filter(dim, dim[product#] =fact[product#] && dim[Date] =_dt),Dim[value])

 

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@rishirajdeb , Assume you have date or create a date from month year

date = "01-" & [Month year] //change data type to date


New column in Fact =

var _dt = maxx(filter(dim, dim[product#] =fact[product#] && dim[Date]<=fact[Date]),Dim[Date])
return
fact[amount]* maxx(filter(dim, dim[product#] =fact[product#] && dim[Date] =_dt),Dim[value])

 

thanks @amitchandak, it's really helpful !!

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.