Forum Discussion

rodg's avatar
rodg
Frequent Visitor
2 years ago
Solved

A Slowly Changing Dimension

Hi,

 

I need some help with what I think is a slowly changing dimension. Let me try to explain.

The suppliers are given a time(window) at which they can deliver there goods. This time(window) has a start and end date.
Example: in 2023 delivery between 07:00 and 08:00, in 2024 delivery between 06:00 and 07:00

 

So I would like to compare their effective delivery time with their planned time. Of course taking their schedule into account.

 

There are main 3 tables : Supplier, Planned, Delivery :

Supplier is the Supplier dimension table. Planned has the planned schedule for each supplier and Delivery is my fact table.

 

Supplier
S1
S2

 

Planned

Supplierstart dateend dateplanned time beginplanned time end
S101/01/202331/12/202307:0008:00
S101/01/202431/12/202406:0007:00
S215/01/202314/01/202410:0011:00
S215/01/202414/01/202511:0012:00


Delivery table

datesupplierordereddelivery time
01/01/2023S11106:30
02/01/2023S12107:30
03/01/2024S13108:30
04/01/2024S14105:30
05/01/2024S15106:30
06/01/2024S16107:30



This is the relationship schema.

 

 

So the outcome should look like this

dataSupplierordereddelivery timeplanned time beginplanned time endresult
01/01/2023S11106:3007:0008:00not on time
02/01/2024S12107:3007:0008:00on time
03/01/2024S13108:3007:0008:00not on time
04/01/2024S14105:3006:0007:00not on time
05/01/2024S15106:3006:0007:00on time
06/01/2024S16107:3006:0007:00not on time

 

Both a dax and a power query solution are okay. No idea what would be better.
Hopefully someone can help or at least get me started

 

Ronny

 

 

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi rodg 

    You can refer to the following solution, the sample data and the relationship is  the same as you provided.

    Start_date = MAXX(FILTER(Planned,YEAR([start date])=YEAR(MAX(D_Date[Date]))&&[start date]<=MAX(D_Date[Date])&&[end date]>MAX(D_Date[Date])),[start date])
    Begin_time = MAXX(FILTER(Planned,[start date]=[Start_date]&&[end date]=[End_date]),[planned time begin])
    Begin_time = MAXX(FILTER(Planned,[start date]=[Start_date]&&[end date]=[End_date]),[planned time begin])
    End_time = MAXX(FILTER(Planned,[start date]=[Start_date]&&[end date]=[End_date]),[planned time end])
    result = IF(MAX(F_Delivery[delivery time])>=[Begin_time]&&MAX(F_Delivery[delivery time])<[End_time]&&[Start_date]<>BLANK(),"on time",IF([Start_date]<>BLANK(),"not on time"))

    Then put the result measure, start time measure and end time measure to the visual.

     

    Output

    Best Regards!

    Yolo Zhu

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

1 Reply

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi rodg 

    You can refer to the following solution, the sample data and the relationship is  the same as you provided.

    Start_date = MAXX(FILTER(Planned,YEAR([start date])=YEAR(MAX(D_Date[Date]))&&[start date]<=MAX(D_Date[Date])&&[end date]>MAX(D_Date[Date])),[start date])
    Begin_time = MAXX(FILTER(Planned,[start date]=[Start_date]&&[end date]=[End_date]),[planned time begin])
    Begin_time = MAXX(FILTER(Planned,[start date]=[Start_date]&&[end date]=[End_date]),[planned time begin])
    End_time = MAXX(FILTER(Planned,[start date]=[Start_date]&&[end date]=[End_date]),[planned time end])
    result = IF(MAX(F_Delivery[delivery time])>=[Begin_time]&&MAX(F_Delivery[delivery time])<[End_time]&&[Start_date]<>BLANK(),"on time",IF([Start_date]<>BLANK(),"not on time"))

    Then put the result measure, start time measure and end time measure to the visual.

     

    Output

    Best Regards!

    Yolo Zhu

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.