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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.