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
Anonymous
Not applicable

Getting a value from unrelated table based on a date span

I've got a table containing a creation date. From an unrelated table I want to get the value from the Release column when the creation date is between the Start date and the Releasedate.

 

Releaseversion

ReleaseReleasedateStart
21:22021-12-062021-04-01
22:12022-02-222021-12-07
22:22022-05-102021-02-23

 

Values

SkapadIDStatus
2021-12-01 07:01:001Avslutad
2022-02-20 16:15:002Avslutad
2022-02-23 09:30:003Pågående

 

So that I end up with

SkapadIDStatusRelease
2021-12-01 07:01:001Avslutad21:1
2022-02-20 16:15:002Avslutad22:1
2022-02-23 09:30:003Pågående22:2

 

I tried added a custom column in the Power Query Editor but at the moment I just keep getting the error message "cannot convert a value of type Table to type List"

 

Table.ToColumns(Table.First(Table.Column(Table.SelectRows(
Table.FromRecords(Table.SelectRows(
#"Releasedatum",
each [Releasedatum] <= [Skapad] &&
), each [Start] >= [Skapad])),[Release])))

 

Any help would be much appreciated!

1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @Anonymous ,

Here are the steps you can follow:

1. Create calculated column.

Release =
CALCULATE(MIN('Releaseversion'[Release]),FILTER(ALL('Releaseversion'),'Values'[Skapad]>='Releaseversion'[Start]&&'Values'[Skapad]<='Releaseversion'[Releasedate]))

2. Result:

vyangliumsft_0-1646035121466.png

 

Best Regards,

Liu Yang

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

View solution in original post

4 REPLIES 4
v-yangliu-msft
Community Support
Community Support

Hi  @Anonymous ,

Here are the steps you can follow:

1. Create calculated column.

Release =
CALCULATE(MIN('Releaseversion'[Release]),FILTER(ALL('Releaseversion'),'Values'[Skapad]>='Releaseversion'[Start]&&'Values'[Skapad]<='Releaseversion'[Releasedate]))

2. Result:

vyangliumsft_0-1646035121466.png

 

Best Regards,

Liu Yang

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

Anonymous
Not applicable

Yes, thank you very much, that worked for me!

 

johnt75
Super User
Super User

You could add a calculated column in DAX, such as

Release Version =
var currentDate = Values[Skapad]
SELECTCOLUMNS(
TOPN( 1,
FILTER( ReleaseVersion, ReleaseVersion[Start] <= currentDate && ReleaseVersion[ReleaseDate] >= currentDate ),
ReleaseVersion[ReleaseDate]
),
"Release", ReleaseVersion[Release]
)

You may want to change the <= and >= to < and > depending on your business logic

Anonymous
Not applicable

Thanks for replying, I couldn't get that solution to work but it worked out according to the solution above!

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.