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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Fadian4
Regular Visitor

Calculate quantity per month

Hi, anyone please help me. 

 

I want to create report like this.

Fadian4_2-1662116965187.png

 

I want to calculate quantity consumption each month and per item which have transaction type = sale, negative adjustment, and consumption align with month from posting date. 

Month 0 means --> current month

Month -1 means --> previous month 

Month -2 means --> 2 month ago

etc

 

So, if we open the dashboard on September 2022 , system will show like these:

1. Month 0 --> total of  quantity with posting date = September 2022, each item wich have transaction type = sale, negative adjustment, and consumption

2. Month -1 -->total of  quantity with posting date = August 2022, each item wich have transaction type = sale, negative adjustment, and consumption

3. Month -2 -->total of  quantity with posting date = July 2022, each item wich have transaction type = sale, negative adjustment, and consumption

etc

 

I've write on DAX like this, but it doesn't work:

 

Month_-1 =
VAR Month_Now = MONTH(NOW())
return
CALCULATE(
SUM(ItemMaster_ILE_Purchase[Quantity]),
ItemMaster_ILE_Purchase[Entry_Type]="Sale"||ItemMaster_ILE_Purchase[Entry_Type]="Consumption"||ItemMaster_ILE_Purchase[Entry_Type]="Negative Adjmt.",
Month(ItemMaster_ILE_Purchase[Posting_Date])=Month_Now-1
ALLEXCEPT(ItemMaster_ILE_Purchase,ItemMaster_ILE_Purchase[number])

)

 

The result always be like this. The value always blank eventhough I've already write Month(Now())+4 to get January 2023 value

Fadian4_3-1662117179582.png

 

 

*We didn't use filter date , because we want this dashboard automatically calculated each month without filtering

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

Hi @Fadian4 ,

 

This is my test table:

vyadongfmsft_1-1662624574022.png

 

Please try following DAX:

Month 0 = 
CALCULATE(
    SUM('Table'[Quanity]),
    FILTER('Table',
    'Table'[Entry_Type] IN{ "Sale" ,
     "Negative Adjmt" ,
    "Consumption"}
    && EOMONTH('Table'[Date],0)=EOMONTH(TODAY(),0)
    )
)

Month -1 = 
CALCULATE(
    SUM('Table'[Quanity]),
    FILTER('Table',
    'Table'[Entry_Type] IN{ "Sale" ,
     "Negative Adjmt" ,
    "Consumption"}
    && EOMONTH('Table'[Date],0)=EOMONTH(TODAY(),-1)
    )
)

Month -2 = 
CALCULATE(
    SUM('Table'[Quanity]),
   FILTER('Table',
    'Table'[Entry_Type] IN{ "Sale" ,
     "Negative Adjmt" ,
    "Consumption"}
    && EOMONTH('Table'[Date],0)=EOMONTH(TODAY(),-2)
    )
)

 

You will get the result you want:

vyadongfmsft_0-1662624534890.png

Best regards,

Yadong Fang

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

Hi @Fadian4 ,

 

This is my test table:

vyadongfmsft_1-1662624574022.png

 

Please try following DAX:

Month 0 = 
CALCULATE(
    SUM('Table'[Quanity]),
    FILTER('Table',
    'Table'[Entry_Type] IN{ "Sale" ,
     "Negative Adjmt" ,
    "Consumption"}
    && EOMONTH('Table'[Date],0)=EOMONTH(TODAY(),0)
    )
)

Month -1 = 
CALCULATE(
    SUM('Table'[Quanity]),
    FILTER('Table',
    'Table'[Entry_Type] IN{ "Sale" ,
     "Negative Adjmt" ,
    "Consumption"}
    && EOMONTH('Table'[Date],0)=EOMONTH(TODAY(),-1)
    )
)

Month -2 = 
CALCULATE(
    SUM('Table'[Quanity]),
   FILTER('Table',
    'Table'[Entry_Type] IN{ "Sale" ,
     "Negative Adjmt" ,
    "Consumption"}
    && EOMONTH('Table'[Date],0)=EOMONTH(TODAY(),-2)
    )
)

 

You will get the result you want:

vyadongfmsft_0-1662624534890.png

Best regards,

Yadong Fang

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

amitchandak
Super User
Super User

@Fadian4 , Create a new column in your date table

 

Month No  = "Month" & format(-1* datediff(eomonth(today(),0), eomonth([Date],0), Month) , "00")

 

and use that in visual

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

hi, thank you for your advice.

but still doesn't work on me. the output just "Month 00"

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.