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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

finding value of stock amount for each month

Hi,

 

I want to find stock value of products for each month. Addition to fallowing tables, I also have a product table related to both tables. Each product have different price for each month. I need to multiply cumulative stock amount with price of the product for each month. I will be appreciated for any idea about how to do that. Thanks.

 

stock table

product_id 
price 
month 
year 

 

price table

product_id
action_date
amount

 

 

1 REPLY 1
v-lionel-msft
Community Support
Community Support

Hi @Anonymous ,

Are your tables like these?

d7.PNGd8.PNG

If yes, you can solve your issue like this:

In 'Price table':

first, split the [action_date] column into [Year] and [month] columns;

Year = YEAR([action_date]) 
Month = MONTH([action_date])

Second, create related columns:

 

// In 'Price table'
cumulative stock amount for each month = 
CALCULATE(
    SUM('price table'[amount]),
    FILTER(
        'price table',
        [Month] = EARLIER([Month])
        &&
        [Year] = EARLIER([Year])
        &&
        [product_id] = EARLIER([product_id])
    )
)

//In 'stock table':
Price for each product for each month = 
CALCULATE(
    SUM([price]),
    FILTER(
        'stock table',
        [product_id] = EARLIER([product_id])
        &&
        [year] = EARLIER([year])
        &&
        [month] = EARLIER([month])
    )
) 
// Then, create another column in 'price table':
Price for each product for each month = 
LOOKUPVALUE(
    'stock table'[Price for each product for each month],
    'stock table'[product_id], 'price table'[product_id],
    'stock table'[month], 'price table'[Month],
    'stock table'[year], 'price table'[Year]
)

 

 

Third, create a measure:

stock value of products for each month = 
SUMX(
    'price table',
    [cumulative stock amount for each month] * [Price for each product for each month]
)

 

The result:

d9.PNG

 

Is this problem solved?

If it is solved, could you kindly accept it as a solution to close the case?

if not, feel free to let me know.

Best regards,
Lionel Chen

 

 

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

Top Solution Authors
Top Kudoed Authors