Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Gareth_Hunt
Helper II
Helper II

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

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@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])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

@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])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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)"

 
 

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

Gareth_Hunt_0-1597147145707.png

thanks for your help though

 

 

Hi, that is the "transform data" view. That query editor is for power query language transformations. Amit has sent you a DAX formula as you have asked. Check this doc that will help you build Amit's solution to validate it.

https://docs.microsoft.com/en-us/power-bi/transform-model/desktop-tutorial-create-calculated-columns

 

Regards,


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

Happy to help!

LaDataWeb Blog

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.