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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
dearears
Helper I
Helper I

FEFO Violation

Hi,

Trying to put a flag ("X") on Articles that were shipped violating FEFO (First Expiry First Out)

 

Logic: shipment violated FEFO if for the article, expiry date on shippment is earlier than expiry date of shipments previously made.

 

Thanks in advance.

 

Table:

ArticleExpiry dateShipped OnViolation Flag
A01.01.202001.02.2020 
A01.02.202005.02.2020 
A01.01.202006.02.2020x
A01.04.202008.02.2020 
B01.01.202001.02.2020 
B01.02.202005.02.2020 
B01.01.202006.02.2020x
B01.04.202008.02.2020 

 

Example:

I am about to make a shipment today. (18.03.2022).

I choose to ship article A with expiry date of 1 Jan 2021.

FEFO is violated if before today, a batch of Article A was shipped with an expiry date more than 1 Jan 2021.

Or in other words, FEFO is met, if batches shipped before today were shipped with expiry date before 1 Jan 2021.

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

Hi  @dearears ,

Here are the steps you can follow:

1. In Power query. Add Column – Index Column – From 1.

vyangliumsft_0-1647935909502.png

2. Create calculated column.

Violation Flag =
var _current=CALCULATE(MAX('Table'[Expiry date]),FILTER(ALL('Table'),'Table'[Article]=EARLIER('Table'[Article])&&'Table'[Index]=EARLIER('Table'[Index])))
var _Before=CALCULATE(MAX('Table'[Expiry date]),FILTER(ALL('Table'),'Table'[Article]=EARLIER('Table'[Article])&&'Table'[Index]=EARLIER('Table'[Index])-1))
return
IF(
    _current<_Before,"x",BLANK())

3. Result:

vyangliumsft_1-1647935909503.png

 

Best Regards,

Liu Yang

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

4 REPLIES 4
v-yangliu-msft
Community Support
Community Support

Hi  @dearears ,

Here are the steps you can follow:

1. In Power query. Add Column – Index Column – From 1.

vyangliumsft_0-1647935909502.png

2. Create calculated column.

Violation Flag =
var _current=CALCULATE(MAX('Table'[Expiry date]),FILTER(ALL('Table'),'Table'[Article]=EARLIER('Table'[Article])&&'Table'[Index]=EARLIER('Table'[Index])))
var _Before=CALCULATE(MAX('Table'[Expiry date]),FILTER(ALL('Table'),'Table'[Article]=EARLIER('Table'[Article])&&'Table'[Index]=EARLIER('Table'[Index])-1))
return
IF(
    _current<_Before,"x",BLANK())

3. Result:

vyangliumsft_1-1647935909503.png

 

Best Regards,

Liu Yang

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

Many thanks. 

amitchandak
Super User
Super User

@dearears , A new column

if([Expiry date] <[Shipped on] , 1, blank() )

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Hi @amitchandak , Wish it was that simple 😀 This is not what I was after. Let me rephrase with an example.

 

I am about to make a shipment today. (18.03.2022).

I choose to ship article A with expiry date of 1 Jan 2021.

FEFO is violated if before today, a batch of Article A was shipped with an expiry date more than 1 Jan 2021.

Or in other words, FEFO is met, if batches shipped before today were shipped with expiry date before 1 Jan 2021.

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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