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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. 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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.