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
SwatKat
Frequent Visitor

Look up within Same Table based on Order Created Date

Hi,

 

I have a Orders  table as below in my Power BI file . I need to show list of customers who have Ordered Online in the past. This will be used in a table visual. I tried Look Up but that is not working.  I am unable to understand how to achieve this in M Query either. Any inputs are highly appreciated.  I have tried to created measure too , but that did not work as well 😞 

 

OrderID       OrderCreatedDate          Source       CustomerID      
900011/13/2023Email520005
900021/23/2023Form520005
900033/14/2023Online520005
900045/16/2023Email520005
900051/13/2023Email520006
900061/23/2023Form520006
900073/14/2023Online520006
900085/16/2023Form520006
900094/17/2023Email520007
900105/16/2023Form520007
900116/17/2023Form520007

 

 

 

Expected Output

 

CustomerID       Orderered Online in Past     
520005Yes
520006Yes
520007No

 

Tagging Top solution others since this is something i need to close quickly @Martin_D , @lbendlin , @parry2k , @Ashish_Mathur , @amitchandak . I hope you understand my tight timeline

1 ACCEPTED SOLUTION
Martin_D
Super User
Super User

Hi @SwatKat ,

I'd recommend to solve this problem in a measure, not in M Query. This DAX measure

 

 

Has ordered online = IF ( "Online" in VALUES ('Orders'[Source] ), "Yes", "No" )

 

 

will give you this result:

Martin_D_0-1695016680251.png

Kind regards,

Martin

github.pnglinkedin.png

View solution in original post

3 REPLIES 3
Martin_D
Super User
Super User

Hi @SwatKat ,

I'd recommend to solve this problem in a measure, not in M Query. This DAX measure

 

 

Has ordered online = IF ( "Online" in VALUES ('Orders'[Source] ), "Yes", "No" )

 

 

will give you this result:

Martin_D_0-1695016680251.png

Kind regards,

Martin

github.pnglinkedin.png

alexschindler
Frequent Visitor

Hi SwatKat

Can you not use some measure for this?

Something along the lines of ...

ordered_online =
VAR ordered_online_in_past = CALCULATE(DISTINCTCOUNT(order_table[OrderID]), FILTER('orders_table', orders_table[Source] = "Online"))
RETURN
IF(ordered_online_in_past > 0,
"yes",
"no"
)

Good luck

Alex

Thanks Alex for your solution. I have tried solution provided by @Martin_D  and it worked. It looks like your solution will work pretty fine too. 

 

Thanks for the prompt responses

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.