简体   繁体   中英

In the Films table create a calculated column called NumberBreaks which shows for each film the number of breaks needed

The Films table looks like this

在此处输入图片说明

There is a ComfortBreaks table looking like image

在此处输入图片说明

In the Films table I need to create a calculated column called NumberBreaks which shows for each film the number of breaks needed. To do this I have to pick out the value of the Breaks column where:

The value of the lower limit in the ComfortBreaks table is less than or equal to this film's running time in minutes and The value of the upper limit in the ComfortBreaks table is greater than this film's running time in minutes.

the result should look like the image below

在此处输入图片说明

There cannot be a relationship between the two tables. so this has to be done without creating relationship between them.

I tried lookup function but it showed error:A table of multiple values was supplied where a single value was expected.

You can use this below code for your custom column. Considering

number_of_breaks = 

VAR current_row_run_time_minutes = Films[RunTimeMinutes]

RETURN 
MINX (
    FILTER(
        ComfortBreaks,
        ComfortBreaks[LowerLimit] <= current_row_run_time_minutes
            && ComfortBreaks[UperLimit] > MonthNumber
    ),
    ComfortBreaks[Breaks]
)

You can perform your further average calculation on the new custom column now.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM