Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago

Return a value based on a postingdate

Hello Community

 

I have checked some posting and I am not sure how to go about this.

 

I have 2 tables

Table1 has some items, amounts and a saledate

Table2 has the date ranges and the week number


Table 1

ItemSaleDate(ddmmyyy)Amount
abc0101202083
def1801202073
ghi1902202011
jkl1801202027

 

Table 2 (date table)

StartDate (ddmmyyy)EndDate (ddmmyyy)PeroidName
0101202007012020W1
0801202015012020W1
1601202023012020W2
   

 

What I need is to return the PeroidName that falls inbetween the date rate. Without calculating the sum on that day.

 

Thank you kindly

1 Reply

  • mahoneypat's avatar
    mahoneypat
    Icon for Microsoft Employee rankMicrosoft Employee

    I assume you are looking for a calculated column.  You can try this expression:

     

    PeriodName = var datethisrow = Table1[SaleDate]

    return Calculate(min(Table2[PeriodName), Filter(All(Table2), Table2[StartDate] <= datethisrow && Table2[EndDate]>= datethisrow))

     

    If this solution works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

    Regards,

    Pat