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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
alisag09
Regular Visitor

First Record based on the Date

Hello All,

I have to Tables, Products and PurchaseLines and relation is between these 2 is ItemID. To print the earliest Receipt Possible Date for a ItemID, i can use Earliest but how can i get the corresposnding Purchase OrderNo for that record in PurchaseLines Table, similar to below,

ItemIDEarliest Receipt DatePurchaseID
ABCDEF20/02/2023PO0000023
XYZEFG12/03/2023PO0000086

 

for ABCDEF ItemID i have 4 PO lines with 4 differnet PO# and dates.

ITEMIDPurchIDReceiptDate
ABCDEFPO000001928/02/2023
ABCDEFPO000002320/02/2023
ABCDEFPO000003808/03/2023
ABCDEFPO000005617/04/2024
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @alisag09 ,

Please refer to my pbix file.

Create measures.

date_ = CALCULATE(MIN(purchase[DeliveryDate]),FILTER(ALL(purchase),purchase[ItemId]=SELECTEDVALUE(products[ItemNumber])))
Description = "Description of -" &"  "&MAX(products[ItemNumber])
Earliest PurchdID = CALCULATE(MAX(purchase[PurchID]),FILTER(ALL(purchase),purchase[ItemId]=SELECTEDVALUE(products[ItemNumber])))

vpollymsft_0-1675063583448.png

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Polly

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

6 REPLIES 6
Anonymous
Not applicable

Hi @alisag09 ,

Please refer to my pbix file.

Create measures.

date_ = CALCULATE(MIN(purchase[DeliveryDate]),FILTER(ALL(purchase),purchase[ItemId]=SELECTEDVALUE(products[ItemNumber])))
Description = "Description of -" &"  "&MAX(products[ItemNumber])
Earliest PurchdID = CALCULATE(MAX(purchase[PurchID]),FILTER(ALL(purchase),purchase[ItemId]=SELECTEDVALUE(products[ItemNumber])))

vpollymsft_0-1675063583448.png

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Polly

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

Many thanks Polly....it worked.

alisag09
Regular Visitor

Hello,

Thanks Polly, but May i kNow which Table is what? Can you please rewrite the Query Using Table Names as

ItemTable & PurchTable at least for Column Query?

Anonymous
Not applicable

Hi @alisag09 ,

It seems you have 2 tables. Could you please provide a screenshot with your desired output? 

You can provide some data like you have provided.

And the desired output like the following, let me know  you want.

vpollymsft_0-1675061485299.png

 

Best Regards
Community Support Team _ Polly

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

Anonymous
Not applicable

Hi @alisag09 ,

Please have a try.

Create a measure.

measure =
MINX (
    FILTER ( ALL ( table ), table[item id] = SELECTEDVALUE ( table[item id] ) ),
    table[receiptdate]
)

Or a column.

column =
MINX (
    FILTER ( ( table ), table[item id] = EARLIER ( table[item id] ) ),
    table[receiptdate]
)

How to Get Your Question Answered Quickly 

 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Polly

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

 

Hello, Following are 2 Tables Namely Products & Purchase

Products,

ItemNumber 
0110322 
0110323 
0110328 
0110334 
0110401 
0110493 
0230116 

 

Purchase

PurchIDItemIdDeliveryDate
PO-00073001103222/6/2023
PO-00073001103223/6/2023
PO-00073001103224/6/2023
PO-00073001103234/24/2023
PO-00073001103234/24/2023
PO-00073001103234/24/2023
PO-00024801103281/27/2023
PO-00073001103342/6/2023
PO-00073001103343/6/2023
PO-00073001103344/6/2023
PO-00073001104012/6/2023
PO-00073001104013/6/2023
PO-00073001104932/6/2023
PO-00073001104933/6/2023
PO-00073001104934/6/2023

 

Result 

 

ItemNumberDescriptionEarliest DateEarliest PurchdID
0110322Description of - 01103222/6/2023PO-000730
0110323Description of - 01103234/24/2023PO-000730
0110328Description of - 01103281/27/2023PO-000248
0110334Description of - 01103342/6/2023PO-000730
0110401Description of - 01104012/6/2023PO-000730
0110493Description of - 01104932/6/2023PO-000715
0230116Description of - 0230116  
0230135Description of - 0230135  
0230158Description of - 0230158  
0240107Description of - 0240107  
0240108Description of - 0240108  

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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