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
nicolasvc
Helper III
Helper III

calculate data from other tables and from the same column in process

I have a table with the price of a product per year and month, I also have another which I pivoted to have the growth percentage of each product per year. And I need to form a table in which I have the prices of the product but with the percentage increase. The problem is that for the first year, 2022, I have to calculate it based on the first table, but then for 2023 and those that follow, I have to start from the previous year, which would be 2022 in the case of 2023, and so on.
And I don't know how to calculate 2022 by obtaining the data from the other tables, and even less the ones that follow.

yearmonthproductprice
20211A2000
20211B1000
20212A1000
20212B2010
............

 

productyearpercentage
A20221.4%
B20222.2%
A20233.1%
B20231.4%

 

And I need to form a table in which I have the prices of the product but with the percentage increase. The problem is that for the first year, 2022, I have to calculate it based on the first table, but then for 2023 and those that follow, I have to start from the previous year, which would be 2022 in the case of 2023, and so on.
And I don't know how to calculate 2022 by obtaining the data from the other tables, and even less the ones that follow.

 

disclaimer: the values that are there are not correct

yearmonthproductprice
20221A2500
20221B1500
............
20231A2500
1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

You measure might look something like this:

Predicted Price =
VAR CurrYear = SELECTEDVALUE ( DimDate[Year] )
VAR CurrMonth = SELECTEDVALUE ( DimDate[Month] )
VAR CurrProduct = SELECTEDVALUE ( Prices[product] )
VAR StartPrice =
    LOOKUPVALUE (
        Prices[price],
        Prices[product], CurrProduct,
        Prices[month], CurrMonth
    )
VAR GrowthFactor =
    PRODUCTX (
        FILTER ( Growth, Growth[product] = CurrProduct && Growth[year] <= CurrYear ),
        1 + Growth[percentage]
    )
RETURN
    StartPrice * IF ( CurrYear = MIN ( Prices[year] ), 1, GrowthFactor )

 

Details will vary but the key logic is that you use StartingPrice * ( 1 + % ) * ( 1 + % ) where you have one % value for each year beyond the starting year.

View solution in original post

6 REPLIES 6
v-henryk-mstf
Community Support
Community Support

Hi @nicolasvc ,

 

Try the way @AlexisOlson  gave to see if it works. If there is still a problem, please provide details of the confusion and I will answer it for you as soon as possible.


Looking forward to your reply.


Best Regards,
Henry

 

AlexisOlson
Super User
Super User

You measure might look something like this:

Predicted Price =
VAR CurrYear = SELECTEDVALUE ( DimDate[Year] )
VAR CurrMonth = SELECTEDVALUE ( DimDate[Month] )
VAR CurrProduct = SELECTEDVALUE ( Prices[product] )
VAR StartPrice =
    LOOKUPVALUE (
        Prices[price],
        Prices[product], CurrProduct,
        Prices[month], CurrMonth
    )
VAR GrowthFactor =
    PRODUCTX (
        FILTER ( Growth, Growth[product] = CurrProduct && Growth[year] <= CurrYear ),
        1 + Growth[percentage]
    )
RETURN
    StartPrice * IF ( CurrYear = MIN ( Prices[year] ), 1, GrowthFactor )

 

Details will vary but the key logic is that you use StartingPrice * ( 1 + % ) * ( 1 + % ) where you have one % value for each year beyond the starting year.

That likely means that LOOKUPVALUE is not finding a single unique value (or else CurrProduct or CurrMonth is blank).

 

It works when I set up the example data

AlexisOlson_0-1633706244101.png

Your data may have additional complexity that I didn't anticipate (since I can't see it...). My suggested measure was just meant to demonstrate the basic logic. It's very likely you'll need to adapt it to your particular situation.

thanks for the answer, but for some reason the StartPrice variable is always empty 😞

AlexisOlson
Super User
Super User

So the price for A in month 1 of 2022 would be 2000 * 1.014 and 1000 * 1.014 for month 2 of 2022?

Yes, exactly.

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.

Top Solution Authors