Forum Discussion

Daniel_Mostert's avatar
Daniel_Mostert
Regular Visitor
5 years ago
Solved

Dax Query - Assistance Between Argument

Good day All

 

I am strungling with formulating the below Dax query. PLease could you advise?

 

If the [Actual Diameter] is between Column [Diam1] and Column [Diam2], then the diameter is equal to the value in Column [IsDiam].  

 

In Excel I would use a Vlookup to do this  =VLOOKUP([@[Actual Diameter]],DataTables!$N$3:$P$48,3,1). 

 

What will the equivalent Dax syntax be?

 

 

 

 

 

 

 

 

  • Ashish_Mathur's avatar
    Ashish_Mathur
    5 years ago

    Hi,

    This calculated column formula works

    Real Diameter = 

    CALCULATE(MIN(Ranges[IsDiam]),FILTER(Ranges,Ranges[Diam1]<=EARLIER(Data[Actual Diameter])&&Ranges[Diam2]>=EARLIER(Data[Actual Diameter])))

    Hope this helps.

6 Replies

    • Fowmy's avatar
      Fowmy
      Icon for Super User rankSuper User

      Daniel_Mostert 

      Better create a new question with the same content and include more details and samples.

  • ActualDiameter
    9.6
    16.11
    21.86
    21.06
    18.08

     

    Diam1 Diam2 IsDiam
    0 12.9 11
    13 14.9 13
    15 16.9 15
    17 18.9 17
    19 20.9 19
    21 22.9 21

     

    RealDiameter 
    11
    15
    21

    21
    17

    • Ashish_Mathur's avatar
      Ashish_Mathur
      Icon for Super User rankSuper User

      Hi,

      This calculated column formula works

      Real Diameter = 

      CALCULATE(MIN(Ranges[IsDiam]),FILTER(Ranges,Ranges[Diam1]<=EARLIER(Data[Actual Diameter])&&Ranges[Diam2]>=EARLIER(Data[Actual Diameter])))

      Hope this helps.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Daniel_Mostert ,

     

    From your description, it seems that you want to use DAX functions to return the same output as when use VLOOKUP() in Excel, right? 

     

    But sorry for that I could not get enough useful information to make the problem very clear to me. 

     

    Please provide me with more details (such as some screenshots)about your table and the expected output in Table format or share me with your pbix file after removing sensitive data.

     

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