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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
spencer_II
Helper I
Helper I

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:

spencer_II_1-1709302555519.png

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 3
v-jianpeng-msft
Community Support
Community Support

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:

vjianpengmsft_0-1709537663711.png

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] ) )
    )
)

 

vjianpengmsft_1-1709537790881.png

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.

 

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.

Greg_Deckler
Super User
Super User

@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.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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