Forum Discussion

Rasmus7700's avatar
Rasmus7700
Frequent Visitor
2 years ago
Solved

Check if value is in range

Hello Guys.  looking around and read a lot of posts - but can't find one that fits my needs completely...    I have two tables, one called "structure" and another called "posts"   in the "struct...
  • parry2k's avatar
    2 years ago

    Rasmus7700 the logic you explained doesn't make sense in the example. for 225, you want to take the value from 999 from the upper bound, whereas in another example for 2500, you want the value from the lower band. I think the logic should be identical in both cases, no?

     

    Anyhow try using this new INDEX function and see if it gets you what you are looking for.

     

    Description Column in Post Table = 
    VAR __Post = 'Post'[Post]
    RETURN
    SELECTCOLUMNS (
        INDEX ( 
            1,
            FILTER ( ALL ( 'Structure' ), 'Structure'[Key]  <= __Post ),
            ORDERBY ( 'Structure'[Key], DESC )
             ,        MATCHBY ( 'Structure'[Key] )
        ),
        "@Desc", [Desc]
    )