简体   繁体   中英

DAX (calculated column, related tables)

I have a table [Delays] with a column called [Delay]. I also have a table [Ranges] with three columns: [Range], [From] and [To]. I need to create a column in the [Delays] table to display the Range value from the [Ranges] table according to this criteria: 'Delays'[Delay] >= 'Ranges'[From] && 'Delays'[Delay] < 'Ranges'[To].

Help is greatly appreciated.

Try creating a measure using:

 =CALCULATE(
   VALUES(Ranges[Range]), 
   FILTER(Ranges, 
      Delays[Delay] >= Ranges[From] 
      && Delays[Delay] < Ranges[To]
)

Depending on your table, you may need to use the HASONEVALUE function because if delay falls in multiple ranges, the measure will fail.

This is assuming that the Ranges table and Delays table are not joined together. If they are, you can just add the Ranges[Range] from the Delays table.

SUMMARIZE(
   Delays,
   Delays[Delay],
   Range[Ranges]
)

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