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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

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

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

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

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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