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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
christina4444
Helper I
Helper I

Min Posting Date - Total qty of 3 or more

Hi Community! 

 

Can anyone help me with a DAX formula to reflect:

 

If total qty is equal to or greater than 3 then show minimum posting date.  

 

Ex:

Invoice #:    Posting Date:      Qty: 

A                     9/1/23               2

B                     10/5/23             1

 

In this case, I want the formula to return 10/5/23 as 2 + 1 = 3 (minimum qty threshold)

 

Thank you!

Christina

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @christina4444 

 

@Jihwan_Kim Good share!

 

I’m sorry to hear that you’re having trouble calculating the Min Posting Date, here I give you the other method:

 

Here's some dummy data

vnuocmsft_0-1704186420089.png

 

Create a measure, the cumulative sum of Qty is calculated based on the customer group.

vnuocmsft_2-1704186565237.png

 

total Qty = CALCULATE(SUM('Table'[Qty]), FILTER(ALL('Table'),'Table'[Customer] = MAX('Table'[Customer]) && [Posting Date] <= MAX([Posting Date])))

 

 

Create a measure, group according to customer and total Qty greater than or equal to 3, then return the minimum date. And here is the result:

vnuocmsft_3-1704186626067.png

 

_postingDate = MINX(FILTER(ALLSELECTED('Table'), [Customer]=MAX('Table'[Customer]) && [total Qty] >= 3),[Posting Date])

 

 

Regards,

Nono Chen

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

3 REPLIES 3
Anonymous
Not applicable

Hi @christina4444 

 

@Jihwan_Kim Good share!

 

I’m sorry to hear that you’re having trouble calculating the Min Posting Date, here I give you the other method:

 

Here's some dummy data

vnuocmsft_0-1704186420089.png

 

Create a measure, the cumulative sum of Qty is calculated based on the customer group.

vnuocmsft_2-1704186565237.png

 

total Qty = CALCULATE(SUM('Table'[Qty]), FILTER(ALL('Table'),'Table'[Customer] = MAX('Table'[Customer]) && [Posting Date] <= MAX([Posting Date])))

 

 

Create a measure, group according to customer and total Qty greater than or equal to 3, then return the minimum date. And here is the result:

vnuocmsft_3-1704186626067.png

 

_postingDate = MINX(FILTER(ALLSELECTED('Table'), [Customer]=MAX('Table'[Customer]) && [total Qty] >= 3),[Posting Date])

 

 

Regards,

Nono Chen

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

Jihwan_Kim
Super User
Super User

Hi, I am not sure how your semantic model looks like, but I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file.

I hope the below can provide some ideas on how to create a solution for your semantic model.

 

Jihwan_Kim_0-1702440302842.png

 

WINDOW function (DAX) - DAX | Microsoft Learn

 

Expected result measure: = 
VAR _t =
    ADDCOLUMNS (
        SUMMARIZE (
            ALL ( data ),
            data[Group],
            data[Invoice_number],
            data[posting_date],
            data[Qty]
        ),
        "@runningtotalbygroup",
            CALCULATE (
                SUM ( data[Qty] ),
                WINDOW (
                    1,
                    ABS,
                    0,
                    REL,
                    SUMMARIZE (
                        ALL ( data ),
                        data[Group],
                        data[Invoice_number],
                        data[posting_date],
                        data[Qty]
                    ),
                    ORDERBY ( data[posting_date], ASC ),
                    ,
                    PARTITIONBY ( data[Group] ),
                    MATCHBY ( data[Group], data[posting_date], data[Invoice_number] )
                )
            )
    )
VAR _condition =
    FILTER ( _t, data[Group] = MAX ( data[Group] ) && [@runningtotalbygroup] >= 3 )
VAR _startdate =
    MINX ( _condition, data[posting_date] )
RETURN
    _startdate

 


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.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Hi @Jihwan_Kim,

 

Thanks so much for the response!  I feel like your formula is sooo close.  

 

I'm receiving an error message - maybe related to the details I'm including (?)

 

Here is the table I'm looking to add this measure to. (Currently has Earliest Posting Date) but it is not correctly showing since the result shows any posting date with a quantity of 1 or more (versus 3 or more).

 

Table Example.png

 

Here is what I used for a formula in relation to your example:

Min Date Test =
VAR _t =
    ADDCOLUMNS(
        SUMMARIZE(
            ALL ('VALUE ENTRY'),
            'VALUE ENTRY'[Item No],
            'VALUE ENTRY'[Customer],
            'VALUE ENTRY'[Document No],
            'VALUE ENTRY'[Posting Date],
            'VALUE ENTRY'[Quantity]
        ),
        "@runningtotalbyitem",
            CALCULATE(
                SUM('VALUE ENTRY'[Quantity] ),
                WINDOW(
                    1,
                    ABS,
                    0,
                    REL,
                    SUMMARIZE(
                        ALL ('VALUE ENTRY' ),
                        'VALUE ENTRY'[Item No],
                        'VALUE ENTRY'[Customer],
                        'VALUE ENTRY'[Document No],
                        'VALUE ENTRY'[Posting Date],
                        'VALUE ENTRY'[Quantity]
                    ),
                    ORDERBY([Posting Date], ASC ),
                    ,
                    PARTITIONBY('VALUE ENTRY'[Item No] ),
                    MATCHBY('VALUE ENTRY'[Item No], 'VALUE ENTRY'[Customer], 'VALUE ENTRY'[Posting Date], 'VALUE ENTRY'[Document No] )
                )
            )
    )
VAR _condition =
    FILTER( _t, 'VALUE ENTRY'[Item No] = MAX ('VALUE ENTRY'[Item No] ) && [@runningtotalbyitem] >=3 )
VAR _startdate =
    MINX(_condition, 'VALUE ENTRY'[Posting Date] )
RETURN
    _startdate

 

This is the error message I am receiving:

Error Message.png

 

Thanks again! 

Christina

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.