Forum Discussion

Gareth_Hunt's avatar
Gareth_Hunt
Helper II
6 years ago
Solved

help with DAX

Hi Guys,

 

this may be on here twice thought I was signed in before posting but now cannot seethe original post so here goes

 

I would like to  do something that feels very simple but Im new to DAX 

 

I have 3 columns of imported data

TYPEInvoiceOrderSalesman

IN

5556712345JIM
IN5556712345JIM
CR9999855567 
CR9999955568 

 

what I would like to do is create a 4th column in the query editor that 

 

TYPEInvoiceOrderSalesmanSalesman complete

IN

5556712345JIMJIM
IN5556712345JIMJIM
CR9999855567 JIM
CR9999955568  

 I would like to create a DAX equation that returns the following 

 

if TYPE = "IN" then return Salesman value

if TYPE = "CR" then lookup ORDER against INVOICE and return Salesman

IF TYPE = "CR" lookup returns no value then return (blank)

 

I would use vlookup in excell but whath is the DAX equvalient?

 

Many thanks

Gareth

  • Gareth_Hunt , Create a new column like

    new column =
    var _salesm = maxx(filter(Table,table[Order] =earlier([Invoice])),[Salesman])
    return
    if([TYPE] ="IN",[Salesman],[_salesm])

4 Replies

  • Gareth_Hunt , Create a new column like

    new column =
    var _salesm = maxx(filter(Table,table[Order] =earlier([Invoice])),[Salesman])
    return
    if([TYPE] ="IN",[Salesman],[_salesm])

    • Gareth_Hunt's avatar
      Gareth_Hunt
      Helper II

      Hi Sorry  -I dont understand your expression, this is as far as I have got - I have no table reference??

      thanks for your help though

       

       

    • Gareth_Hunt's avatar
      Gareth_Hunt
      Helper II

      Hi Amitchandak,

       

      Ok so I have created a new column as prescribed and im looking to apply your example and its works well thank you guys 

       

      NB removed the [] from around _salesm as it was erroring out in case anyone else looks at this in the future 

       

      "new column =
      var _salesm = maxx(filter(Table,table[Order] =earlier([Invoice])),[Salesman])
      return
      if([TYPE] ="IN",[Salesman],_salesm)"