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
PhilippeJosse
New Member

Calculate new date based on columns in two tables

Dear Forum members, 

unfortunately i was unable to find a matching solution, so thought i would go ahead and post the challange i am confronted with and hoping to find support.

--->

I have a Table A with 36.000 rows, and it grows about 300 rows a month. 

 

IDDateCategoryTarget Date

1

01.02.2024HV..
202.01.2024STD..
302.01.2024HV..

*dd.MM.yyyy

 

And Table B, which is a "calendar" table.

 

DateYearQuarterMonthWeekWeekdayIndicator 1Indicator 2

01.01.2024

2024

Q101-Jan11YesYes
02.01.20242024Q101-Jan12YesNo
03.01.20242024Q101-Jan13NoNo

*dd.MM.yyyy

 

Would like to accomplish to calculate a new value in column Target Date in Table A for each individual row.

Where the starting value is the value Column Date for respective row.

Next, If column Category = HV then Date+2 (days) else Date+1 (day)

 

now, using the calculated date as reference, I would like to find the next (or first date higher than the calculated) date in column Date of Table B where a column Indicator 1= "yes" and Indicator 2 = "no".

 

Appriciate any guidance!

 

Thank 

Philippe

1 ACCEPTED SOLUTION
rajendraongole1
Super User
Super User

Hi @PhilippeJosse - Hope in your tables Date columns is date type

 

create a calculated column in first table, as below:

 

InitialTargetDate =
IF (
    TABA1[Category] = "HV",
    TABA1[Date] + 2,
    TABA1[Date] + 1
)

 

rajendraongole1_1-1721726873487.png

 

 

another calclated column:

TargetDate =
VAR InitialDate =
    IF (
        TABA1[Category] = "HV",
        TABA1[Date] + 2,
        TABA1[Date] + 1
    )
RETURN
    CALCULATE (
        MIN (TABA2[Date]),
        FILTER (
            TABA2,
            TABA2[Date] > InitialDate &&
            TABA2[Indicator 1] = "Yes" &&
            TABA2[Indicator 2] = "No"
        )
    )

 

rajendraongole1_0-1721726818807.png

 

Hope it helps

 

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

1 REPLY 1
rajendraongole1
Super User
Super User

Hi @PhilippeJosse - Hope in your tables Date columns is date type

 

create a calculated column in first table, as below:

 

InitialTargetDate =
IF (
    TABA1[Category] = "HV",
    TABA1[Date] + 2,
    TABA1[Date] + 1
)

 

rajendraongole1_1-1721726873487.png

 

 

another calclated column:

TargetDate =
VAR InitialDate =
    IF (
        TABA1[Category] = "HV",
        TABA1[Date] + 2,
        TABA1[Date] + 1
    )
RETURN
    CALCULATE (
        MIN (TABA2[Date]),
        FILTER (
            TABA2,
            TABA2[Date] > InitialDate &&
            TABA2[Indicator 1] = "Yes" &&
            TABA2[Indicator 2] = "No"
        )
    )

 

rajendraongole1_0-1721726818807.png

 

Hope it helps

 

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





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!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

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