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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Anonymous
Not applicable

Need help solving a practical FIFO issue, DAX measure or calculated column

Hello,

 

I have table that contains some sales data. I want to detect a product rotation issue. Effectively, I want each row to list the MAX production date of ENTRY TYPE SALE on a POSTING DATE that is earlier than the current row's posting date. Desired results in red with notes explaining why:

 

Entry No.Posting DateEntry TypeItem NoProduction DateLast Date(notes)
1104/28/19Sale103/01/1903/03/19refers to entry no 4
1004/28/19Sale103/01/1903/03/19refers to entry no 4
904/27/19Output104/27/19 no return, is not a sale
804/26/19Sale203/05/1903/12/19refers to entry no 7
704/25/19Sale203/12/19 no return, no previous sale
604/24/19Sale303/04/1902/27/19refers to entry no 2
504/23/19Consumption303/18/19 no return, is not a sale
404/22/19Sale103/03/19 no return, no previous sale
304/21/19Output204/21/19 no return, is not a sale
204/20/19Sale302/27/1902/26/19refers to entry no 1
104/19/19Sale302/26/19 no return, no previous sale
1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @Anonymous ,

 

Try the following measure:

Last_date =
VAR Last_Date_Calculation =
    CALCULATE (
        MAXX ( 'Table'; 'Table'[Production Date] );
        FILTER (
            ALL ( 'Table'[Posting Date] );
            'Table'[Posting Date] < MAX ( 'Table'[Posting Date] )
        );
        ALLEXCEPT ( 'Table'; 'Table'[Item No]; 'Table'[Entry Type] )
    )
RETURN
    IF ( Last_Date_Calculation = BLANK (); ""; Last_Date_Calculation )

Regards,

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

6 REPLIES 6
v-cherch-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous 

You may use below calculated column:

Column =
VAR Last_Date_Calculation =
    CALCULATE (
        MAXX ( 'Table', 'Table'[Production Date] ),
        FILTER (
            ALL ( 'Table'[Posting Date] ),
            'Table'[Posting Date] < EARLIER ( 'Table'[Posting Date] )
        ),
        ALLEXCEPT ( 'Table', 'Table'[Item No], 'Table'[Entry Type] )
    )
RETURN
    IF (
        Last_Date_Calculation = BLANK ()
            || 'Table'[Entry Type] <> "Sale",
        BLANK (),
        Last_Date_Calculation
    )

Regards,

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
MFelix
Super User
Super User

Hi @Anonymous ,

 

Try the following measure:

Last_date =
VAR Last_Date_Calculation =
    CALCULATE (
        MAXX ( 'Table'; 'Table'[Production Date] );
        FILTER (
            ALL ( 'Table'[Posting Date] );
            'Table'[Posting Date] < MAX ( 'Table'[Posting Date] )
        );
        ALLEXCEPT ( 'Table'; 'Table'[Item No]; 'Table'[Entry Type] )
    )
RETURN
    IF ( Last_Date_Calculation = BLANK (); ""; Last_Date_Calculation )

Regards,

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Anonymous
Not applicable

The works well as a measure, but is affected by a slicer. It does not perform within the context I was hoping. Is it possible to perform the same function using a calculated column, so I can simply pull it into a table row-by-row? In this case, it would compare against all of the other shipments of that item across the entire table's history.

Hi @Anonymous ,

 

What is the context you were expecting? The measure can be change to overcome the slicer context.

 

Regards,

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Anonymous
Not applicable

@MFelix ,

 

I was able to modify my approach to make use of the formula you provided - thank you!

 

MCKery

Hi @Anonymous 

Glad to hear you've solved it, please accept the helpful reply as solution, that way, other community members will easily find the solution when they get same issue.

Regards,

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors
Top Kudoed Authors