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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
wind0soft
Frequent Visitor

Compare dates with a many to one relationship between the tables and indirect connection

Hello-

 

I have three tables. One with hours logged, one with project information, and another with project parameter fields.  They are linked together with a project ID in all three tables.  What I need is to compare a parameter value date to a record in the hours table. It is a many to one relationship between the hours and parameter values.

 

Hours Table example

Log Dateproject IDhoursPhase (this is the calculated column I need)
1/15/231232Phase 1
1/16/231235Phase 1
1/19/231234Phase 1
2/1/234563Phase 1
2/16/231237Phase 2
2/21/23
4563Phase 1
2/22/231232Phase 2
3/2/231236Phase 3

 

Parameter Values Table

Project IDKick Off DateGo-Live Date
1232/1/233/1/23
4563/1/234/1/23

 

In words what I need is a calculated colum for

Calculated column called "Phase"= IF Log date is less than kick off date, "Phase 1", If Log date is greater than or equal to kick off date but less than go-live date then "Phase 2", if log date is greater than go-live date then "Phase 3".  

 

Do I do a LOOKUPVALUE expression with a IF statement?  Not sure wher to begin.

 

Any help would be greatly appreciated.

1 ACCEPTED SOLUTION
vicky_
Super User
Super User

You're on the right track. I would recommend using the related function, since you've already got a relationship between the project IDs. 

Here's the DAX I used:

Phase = 
var kickOff = RELATED(Params[Kick Off Date])
var goLive = RELATED(Params[Go-Live Date])

return SWITCH(TRUE(), 
    Hrs[Log Date] < kickOff, "Phase 1",
    Hrs[Log Date] >= kickOff && Hrs[Log Date] < goLive, "Phase 2",
    Hrs[Log Date] >= goLive, "Phase 3",
    "??? Phase"
)

 And here's the results I got

vicky__0-1693954864681.png

 

View solution in original post

2 REPLIES 2
wind0soft
Frequent Visitor

That worked perfectly! Thank you!!!

vicky_
Super User
Super User

You're on the right track. I would recommend using the related function, since you've already got a relationship between the project IDs. 

Here's the DAX I used:

Phase = 
var kickOff = RELATED(Params[Kick Off Date])
var goLive = RELATED(Params[Go-Live Date])

return SWITCH(TRUE(), 
    Hrs[Log Date] < kickOff, "Phase 1",
    Hrs[Log Date] >= kickOff && Hrs[Log Date] < goLive, "Phase 2",
    Hrs[Log Date] >= goLive, "Phase 3",
    "??? Phase"
)

 And here's the results I got

vicky__0-1693954864681.png

 

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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