Forum Discussion

spencer_II's avatar
spencer_II
Icon for Helper I rankHelper I
2 years ago

Summarize or Group By with multiple conditions?

So I've "noodled" this for a little too long and am probably overlooking a simple solution.

I have a single table that has product ID, transaction date and expiration date by LOT numbers. Plus transfer qty and on hand.

example:

The objective is to identify above condition.  For item 101550 there was product expiring on 12/26/2024 but transfers

of 210 Cases were made against 4/5/2025 expiring product. The earliest expiring product should be transfered first!!!

After reviewing "manually" using above table these are really outlier issues but tracking and count summaries of these conditions are being reqeusted.

 

Any help is and always appreciated.

 

Spencer_II

3 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Icon for Community Champion rankCommunity Champion

    spencer_II Right, so would need much more information to be able to provide a solution for this but I have done similar stuff and it's fun stuff to work on. If you can provide more information I might be able to take a look. 

    Order Fulfillment - Microsoft Fabric Community

    Delivery Dates - Microsoft Fabric Community

     

    Love the supply chain stuff. Sorry, having trouble following, can you post sample data as text and expected output?
    Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

    Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

    The most important parts are:
    1. Sample data as text, use the table tool in the editing bar
    2. Expected output from sample data
    3. Explanation in words of how to get from 1. to 2.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi, spencer_II 

    If you want to group or summarize your data, you can use the SUMMARIZE function. In this function, you can select the column you want to group or summarize. You can also use the calculate and filter functions together to implement multi-condition filtering. data and group them. I created the following sample data:

    I created a new table and used the SUMMARIZE function to summarize the above data and filter the data with the smallest Exp dt:

     

    Table 2 =
    CALCULATETABLE (
        SUMMARIZE (
            'Table',
            'Table'[item number],
            'Table'[Lot number],
            "Date", CALCULATE ( MIN ( 'Table'[Exp dt] ), FILTER ( 'Table', 'Table'[Exp dt] ) )
        )
    )
    

     

    In your description, for 101550 items, I think it may be because Trs dt is empty, so the corresponding behavior of sum of Trans qty bU/M is empty. You can override a measure to calculate Trans qty bU/M instead of using the default sum aggregation function directly. If you can make a sample pbix file or data that does not contain private data, it will help you solve the problem faster. You can click the link below to learn how to use summarize:

    SUMMARIZE - DAX Guide

     

     

     

    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

    Jianpeng Li

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

     

    • spencer_II's avatar
      spencer_II
      Icon for Helper I rankHelper I

      Thank you for the replies... This has led me in a few solid directions for solutions.  Right now calculated columns to the rescue using a combination of RANKX and OFFSET to complete the necessary conditions to filter on. I'm providing a sample table with some data.  This table is the result of a power query merge of two tables (one for inventory/lot expiration date & a sales table for withdrawal date.

       

       

      ItpWhsItem numberNameLot numberExp dtTrs dtTransfer QtyOn Hand Approve
      Z21B281015486/51 OZ 502496012/28/20241/11/2024-40003916
      Z21B281015486/51 OZ 502496012/28/20241/12/2024-32007832
      Z21B281015486/51 OZ502528612/29/2024nullnull1500
      Z21B281015486/51 OZ50258213/28/2025nullnull2200
      Z21B2810154912/16.9 OZ502496112/22/20241/5/2024-42564161
      Z21B2810154912/16.9 OZ502496112/22/20241/11/2024-42564161
      Z21B2810154912/16.9 OZ502496112/22/20241/12/2024-18248322
      Z21B2810154912/16.9 OZ50257863/21/20251/12/2024-1901311
      Z21B2810155012/33.8 OZ502519412/26/2024nullnull2576
      Z21B2810155012/33.8 OZ50257474/5/20251/11/2024-210798
      Z21B2810155012/33.8 OZ50257474/5/20251/12/2024-4201596
      Z10B2810741843/2x3 LTR144596/4/2025nullnull40
      Z10B2810741843/2x3 LTR183331/10/20261/17/2024-176048
      Z10B2810741843/2x3 LTR183391/11/20261/18/2024-112002415

       

      Thanks again for the review and assistance.