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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Raph
Helper III
Helper III

First 12 months of sales : problem at higher hierarchy level

Hello,

 

I wanted to retrieve the total sold quantity of the first 12 month of each product. This command worked well at product level : 

CALCULATE([Total Quantities],DATESINPERIOD('Sales'[Date],MIN('Sales'[Date]),12,MONTH))

But in my matric, when I want to retrieve the subtotal at category level, this formula doesn't calculate the sum of the 12 first months of sales of each product but the sum of the sales of all products starting from the first transaction in this category + 12 months.

So I thought this could be solved by iterating the table product  : 

SUMX('PRODUCTS,CALCULATE([Total Quantities],DATESINPERIOD('Sales '[Date],MIN('Sales'[Date]),12,MONTH)))
Unfortunately I have the exact same problem : good result at product level but not at the category level.
 
Thank you very much for your help.
 
Raphaël
3 REPLIES 3
jameszhang0805
Resolver IV
Resolver IV

Hi Raph :

       Try like below codes :

微信图片_1.png

 

 

 

 

 

The Date in DATESINERIOD function is Date[Date] not Sales[Date] 

 

amitchandak
Super User
Super User

@Raph , Try like

 

SUMX(values('PRODUCTS'[Product]),CALCULATE([Total Quantities],DATESINPERIOD('Sales'[Date],MIN('Sales'[Date]),12,MONTH)))

 

or

 

SUMX(Summarize('PRODUCTS'[Product],"_1",CALCULATE([Total Quantities],DATESINPERIOD('Sales'[Date],MIN('Sales'[Date]),12,MONTH))),[_1])

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thank you very much for your answer @amitchandak but the 2 commands return exatcly the same result I had before... strange.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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