Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago

Using ProductX with a measure rather than a column

Hi all

 

I've got some sales data where I want to project forward total sales amount based on known year on year % change. The data for the Year on Year % change value is a measure that is calculated based of the results of another table.

 

The data looks like this:

 

YearCountryNameKnown SalesYoYChange
2000Germany$7,364,111 
2001Germany$9,398,5818.30%
2002Germany$12,143,72310.00%
2003Germany$15,186,21712.30%
2004Germany$18,090,81414.00%
2005Germany$20,601,21916.00%
2006Germany$23,360,53515.80%
2007Germany$25,346,27913.10%
2008Germany$26,691,6966.40%
2009Germany$29,295,8412.50%
2010Germany$31,046,735-0.30%
2011Germany$31,308,378-2.80%
2012Germany$32,585,961-3.90%
2013Germany$34,091,290-3.50%
2014Germany$41,924,198-2.80%
2015Germany$43,367,394-1.70%
2016Germany$43,886,104-0.10%
2017Germany$44,127,5090.70%
2018Germany$44,935,1691.40%
2019Germany$46,993,6140.90%
2020Germany -0.60%
2021Germany 2.10%
2022Germany 1.30%
2023Germany 1.50%
2024Germany 1.80%
2025Germany 2.20%
2026Germany 2.40%
2027Germany 2.50%
2028Germany 2.40%
2029Germany 2.30%
2030Germany 2.30%

 

The data I want outputted is an extra column which basically takes the last known sales amount and multiples out the future year on year growth rates. Expected output would be something likefuture sales in the table below.

 

YearCountryNameKnown SalesYoYChangeFuture Sales
2000Germany$7,364,111  
2001Germany$9,398,5818.30% 
2002Germany$12,143,72310.00% 
2003Germany$15,186,21712.30% 
2004Germany$18,090,81414.00% 
2005Germany$20,601,21916.00% 
2006Germany$23,360,53515.80% 
2007Germany$25,346,27913.10% 
2008Germany$26,691,6966.40% 
2009Germany$29,295,8412.50% 
2010Germany$31,046,735-0.30% 
2011Germany$31,308,378-2.80% 
2012Germany$32,585,961-3.90% 
2013Germany$34,091,290-3.50% 
2014Germany$41,924,198-2.80% 
2015Germany$43,367,394-1.70% 
2016Germany$43,886,104-0.10% 
2017Germany$44,127,5090.70% 
2018Germany$44,935,1691.40% 
2019Germany$46,993,6140.90% 
2020Germany -0.60%$ 46,711,652
2021Germany 2.10%$ 47,692,597
2022Germany 1.30%$ 48,312,601
2023Germany 1.50%$ 49,037,290
2024Germany 1.80%$ 49,919,961
2025Germany 2.20%$ 51,018,200
2026Germany 2.40%$ 52,242,637
2027Germany 2.50%$ 53,548,703
2028Germany 2.40%$ 54,833,872
2029Germany 2.30%$ 56,095,051
2030Germany 2.30%$ 57,385,237

 

I'm nearly certain the approach used in this video by Curbal is the way to do it - that is using PRODUCTX iterator function to calculate out. However, ProductX only takes acolumn as a its second argument...but I want to pass a measure.

 

The PRODUCTX function takes as its first argument a table, or an expression that returns a table. The second argument is a column that contains the numbers for which you want to compute the product, or an expression that evaluates to a column.

 

I cannot find a way to do the same thing using a measure - after days of research. Does anyone know of a workaround or how I could potentially parse my measure as a column so the ProductX function can evaulate future sales?

 

Any help would be highly appreciated!

 

Cheers

DM

2 Replies

  • Anonymous , check if measure like this can help

     

    measure =
    var _year = maxx(allselected(Table),Table[Year])
    return
    maxx(filter(Table, Table[year] = _year),[YoYChange])* PRODUCTX(filter(allselected(Table), Table[Year] <=max(Table]) & &Table[year] > _year ), 1+ YoYChange)

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks for the reply amitchandak. I'll have to give that a whirl in the morning...was wondering what that measure is actually doing though?