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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
amien
Helper V
Helper V

How to easily use a VLOOKUP/ApplyMAP not using a JOIN

In Qlik you have this function called ApplyMap:

 

MapTableName:
Mapping LOAD
      ValueIn

      ValueOut
Resident Dates

You can now use this is Table in a regular load script like this:

 

FactTable:

ApplyMap('MapTableName',DateF,Null()) as Week

 

How can i easlily do this in Spark without using a join

 

I was thinking about first loading a dataframe with the ValuesIn,ValuesOut

Then load the FactTable into a second dataframe.

 

How how do i add the new column with the "VLOOKUP"? i don't want to use a join

 

 

 

 

 

1 ACCEPTED SOLUTION
spencer_sa
Solution Supplier
Solution Supplier

Assuming you're refering to doing this in a pySpark Notebook (as opposed to a data pipeline).
A not-necessarily-best-practice* solution if you didn't want to use a join with a broadcasted lookup table would be to use a UDF (user defined function).


Step 1 - create a function that does the mapping, and then wrap it in a user defined function.

Step 2 - use the UDF in a .withColumn statement e.g.   df2 = df.withColumn('column name', UDF('column name'))

* UDFs can have performance implications

View solution in original post

1 REPLY 1
spencer_sa
Solution Supplier
Solution Supplier

Assuming you're refering to doing this in a pySpark Notebook (as opposed to a data pipeline).
A not-necessarily-best-practice* solution if you didn't want to use a join with a broadcasted lookup table would be to use a UDF (user defined function).


Step 1 - create a function that does the mapping, and then wrap it in a user defined function.

Step 2 - use the UDF in a .withColumn statement e.g.   df2 = df.withColumn('column name', UDF('column name'))

* UDFs can have performance implications

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.