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
RafaelAri
Helper II
Helper II

Get the most recent transaction date

Hello to all the experts,

I have a database, that contains Warehouses inventory.

The columns are: Item ID / Warehouse name / qty. in WH / Last transaction date.

My goal is:

Get the most recent transaction date, for items that has total quantity of 0in all WH's, in which they are contained.

In this example: items 101, 104 and 106.

(Asume that the table is sorted by Item ID and Last Trans. date)

Item IDWHQty. in WHDate Last Trans. Item IDWHQty. in WHDate Last Trans.
101A002/01/23Results:101C024/02/23
101B017/01/23 104B005/01/23
101C024/02/23 106D030/03/23
102A12620/02/23     
103A1412/03/23     
104B005/01/23     
105B015/01/23     
105C4116/01/23     
106A020/03/23     
106C025/03/23     
106D030/03/23     
107A131/03/23     
107C001/04/23     
107D002/02/23     
108C1803/01/23     
3 ACCEPTED SOLUTIONS
Jihwan_Kim
Super User
Super User

Hi, Please check the below picture and the attached pbix file.

It is for creating a new table.

 

Jihwan_Kim_0-1680410811624.png

 

 

Expected table = 
VAR _expectedresulttable =
    CALCULATETABLE (
        Data,
        FILTER (
            VALUES ( Data[Item ID] ),
            CALCULATE ( ABS ( SUM ( Data[Qty. in WH] ) ) ) = 0
        )
    )
VAR _groupbylatestdate =
    GROUPBY (
        _expectedresulttable,
        Data[Item ID],
        "@latestdate", MAXX ( CURRENTGROUP (), Data[Date Last Trans.] )
    )
RETURN
    CALCULATETABLE (
        Data,
        TREATAS ( _groupbylatestdate, Data[Item ID], Data[Date Last Trans.] )
    )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

View solution in original post

CNENFRNL
Community Champion
Community Champion

CNENFRNL_0-1680421727671.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

Thanks a lot, it did the work!

View solution in original post

6 REPLIES 6
RafaelAri
Helper II
Helper II

I found some mistakes in this solution, but thanks anyway for your replay 👍

CNENFRNL
Community Champion
Community Champion

CNENFRNL_0-1680421727671.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Thanks a lot, it did the work!

Jihwan_Kim
Super User
Super User

Hi, Please check the below picture and the attached pbix file.

It is for creating a new table.

 

Jihwan_Kim_0-1680410811624.png

 

 

Expected table = 
VAR _expectedresulttable =
    CALCULATETABLE (
        Data,
        FILTER (
            VALUES ( Data[Item ID] ),
            CALCULATE ( ABS ( SUM ( Data[Qty. in WH] ) ) ) = 0
        )
    )
VAR _groupbylatestdate =
    GROUPBY (
        _expectedresulttable,
        Data[Item ID],
        "@latestdate", MAXX ( CURRENTGROUP (), Data[Date Last Trans.] )
    )
RETURN
    CALCULATETABLE (
        Data,
        TREATAS ( _groupbylatestdate, Data[Item ID], Data[Date Last Trans.] )
    )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

Thanks a lot, it did the work!

Ahmedx
Super User
Super User

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.
Get the most recent transaction date.pbix
1.pngScreen Capture #790.png

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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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

October NL Carousel

Fabric Community Update - October 2024

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