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
ABLRP
Regular Visitor

Max quantity by month

Hello,

 

I need to retrieve the MAX per PN M by month. I currently have the below measure, but it is not retriving the correct value. It is retrieving the MAX value per date. The desired output is 81 and not 80.

 

MAX DEMAND (last year) =
CALCULATE(MAX('INVENTORY HISTORY'[QTY]),'INVENTORY HISTORY'[TRANSACTION_TYPE]="ISSUED",'INVENTORY HISTORY'[TRANSACTION CREATED_DATE]>=(DATE(YEAR(NOW())-1,MONTH(NOW()),DAY(NOW()))))

 

ABLRP_2-1637916761423.pngABLRP_1-1637916681788.png

Could you please assist me?

 

Thank you!

Barbara

1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

Hi @ABLRP,

I modify the formula to use both year and month fields as conditions(based on current row date), you can try it if helps:

MAX DEMAND =
VAR currDate =
    MAX ( 'INVENTORY HISTORY'[TRANSACTION CREATED_DATE] )
RETURN
    CALCULATE (
        MAX ( 'INVENTORY HISTORY'[QTY] ),
        FILTER (
            ALLSELECTED ( 'INVENTORY HISTORY' ),
            'INVENTORY HISTORY'[TRANSACTION_TYPE] = "ISSUED"
                && YEAR ( 'INVENTORY HISTORY'[TRANSACTION CREATED_DATE] )
                    = YEAR ( currDate ) - 1
                && MONTH ( 'INVENTORY HISTORY'[TRANSACTION CREATED_DATE] ) = MONTH ( currDate )
        )
    )

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

2 REPLIES 2
v-shex-msft
Community Support
Community Support

Hi @ABLRP,

I modify the formula to use both year and month fields as conditions(based on current row date), you can try it if helps:

MAX DEMAND =
VAR currDate =
    MAX ( 'INVENTORY HISTORY'[TRANSACTION CREATED_DATE] )
RETURN
    CALCULATE (
        MAX ( 'INVENTORY HISTORY'[QTY] ),
        FILTER (
            ALLSELECTED ( 'INVENTORY HISTORY' ),
            'INVENTORY HISTORY'[TRANSACTION_TYPE] = "ISSUED"
                && YEAR ( 'INVENTORY HISTORY'[TRANSACTION CREATED_DATE] )
                    = YEAR ( currDate ) - 1
                && MONTH ( 'INVENTORY HISTORY'[TRANSACTION CREATED_DATE] ) = MONTH ( currDate )
        )
    )

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
amitchandak
Super User
Super User

@ABLRP , Create a measure like below, Use month in place of date if need, create a column for month

 

maxx(summzarize(Table, Table[PN I], Table[Transaction_created_date], "_1", Sum(Table[Qty])), [_1])

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.