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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
Anonymous
Not applicable

xLookup in power bi

Hello Community,

 

I have done this in Excel before but I want to do it in Power BI

So I have 3 Columns Article, Quantity OC, Free Quantity and I want to calculate Quantity available based on these columns 

This is the result I want: 

malekzouaridk_0-1674056896509.png

if the Article showed for the first time I want to take the Quantity Libre, if the article appear again I want the first difference between Quantity Libre and Quantity OC which is 5 in my example and if the article appear again so it's gonna be negative I want it 0 instead of showing negative number. 

 

I use this formula in excel: 

malekzouaridk_1-1674057093661.png

 

Hope that you can help me 

 

Thanks a lot

Malek

1 ACCEPTED SOLUTION
v-stephen-msft
Community Support
Community Support

Hi  @Anonymous ,

 

First, implementing iteration in DAX is extremely complex. If your data is as simple as you provided, you can create an index column group by Article and do two calculations to get the final result. Otherwise, it is recommended that you get the results in Excel and import them into Power BI.

1.Create the index column in Power Query. Reference: How to create group index with Power Query or R - (example in Power BI)

vstephenmsft_0-1674098569990.png

 

2.Do the first calculation.

vstephenmsft_0-1674098723522.png

 

 

 

3.The second to get the final result.
vstephenmsft_1-1674098592242.png

Please download the attachmen for more details.

 

 

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

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Thank you @v-stephen-msft so helpful 🙂

v-stephen-msft
Community Support
Community Support

Hi  @Anonymous ,

 

First, implementing iteration in DAX is extremely complex. If your data is as simple as you provided, you can create an index column group by Article and do two calculations to get the final result. Otherwise, it is recommended that you get the results in Excel and import them into Power BI.

1.Create the index column in Power Query. Reference: How to create group index with Power Query or R - (example in Power BI)

vstephenmsft_0-1674098569990.png

 

2.Do the first calculation.

vstephenmsft_0-1674098723522.png

 

 

 

3.The second to get the final result.
vstephenmsft_1-1674098592242.png

Please download the attachmen for more details.

 

 

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

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors