Forum Discussion

aar0n's avatar
aar0n
Icon for Advocate II rankAdvocate II
8 years ago
Solved

How to create a Calculated Table for Future Values in from a Unique Name list

Hi guys, 

 

I am looking to create a calculated table where the date column starts after a different query ends.

 

Here is a sample table of my Original dataset

TypeNameLast date in datasetLast Known Value 
1a1/31/201710
2b1/31/201715
3c1/31/201712
4d1/31/201720

 

 

What i need, is to apply a formula for each "Name". The formula will take the last known "Value" for each unique "Name", and multiplies by 0.77^(1/12) for all future dates until 2020.

 

an example of what i'm looking for 

TypeNameDateValue 
1a2/1/2018Last known Value (for "Name" a) * 0.77^(1/12)
1a2/2/2018Value predicted above * 0.77^(1/12)
1a2/3/2018Value predicted above * 0.77^(1/12)
1a2/4/2018Value predicted above * 0.77^(1/12)
1a2/5/2018Value predicted above * 0.77^(1/12)
1a2/6/2018Value predicted above * 0.77^(1/12)
1a1/1/2020Value predicted above * 0.77^(1/12)
2b2/1/2018Last known Value (for "Name" b) * 0.77^(1/12)
2b2/2/2018Value predicted above * 0.77^(1/12)
2b1/1/2020Value predicted above * 0.77^(1/12)

 

The biggest issue for me isnt the formula.. ive just been struggling how to figure out how to build a date list for each unique name that starts after the original query ends.

 

 

Thanks a lot for the help,

Aaron

  • Hi aar0n

     

    Try this Calculated Table

    From the Modelling Tab>> New Table

     

    New Table =
    ADDCOLUMNS (
        GENERATE (
            TableName,
            GENERATESERIES ( TableName[Last date in dataset] + 1, DATE ( 2020, 1, 1 ) )
        ),
        "myvalue", TableName[Last Known Value ]
            * .77
            ^ ( 1 / 12 )
    )
  • Zubair_Muhammad's avatar
    Zubair_Muhammad
    8 years ago

    Hi aar0n

     

    In that case, create a New Table which will give you Month Numbers

     

    Table =
    GENERATE (
        TableName,
        GENERATESERIES (
            1,
            DATEDIFF ( TableName[Last date in dataset], DATE ( 2020, 1, 1 ), MONTH )
        )
    )

    Then you can add a calculated column to get Month End Dates

     

    Column =
    EOMONTH ( 'Table'[Last date in dataset], 'Table'[Value] )

     

  • Zubair_Muhammad's avatar
    Zubair_Muhammad
    8 years ago
    HI
     
    From your last post I noticed this. So I think adjusting the POWER by -1 should fix it.
     
    My VALUE =
    'Table'[Last Known Value ]
    * ( 0.77
    ^ ( 1 / 12 ) )
    ^ ('Table'[Value that represents the month]-1)
     

19 Replies

  • Zubair_Muhammad's avatar
    Zubair_Muhammad
    Icon for Community Champion rankCommunity Champion

    Hi aar0n

     

    Try this Calculated Table

    From the Modelling Tab>> New Table

     

    New Table =
    ADDCOLUMNS (
        GENERATE (
            TableName,
            GENERATESERIES ( TableName[Last date in dataset] + 1, DATE ( 2020, 1, 1 ) )
        ),
        "myvalue", TableName[Last Known Value ]
            * .77
            ^ ( 1 / 12 )
    )
    • aar0n's avatar
      aar0n
      Icon for Advocate II rankAdvocate II

      That worked amazing! thank you so much!

       

      would you be able to explain how youre using the Addcolumns, generate, and Generateseries together?

       

      for future reference (i'm definitely going to be using this again) i am also wondering how you would do the same process, except the dates increase  by 1 month instead of 1 day

      • Zubair_Muhammad's avatar
        Zubair_Muhammad
        Icon for Community Champion rankCommunity Champion

        Hi aar0n

         

        Basically You have to work backwards.

         

        GenerateSeries creates Table of Dates you need

        Generate crossjoins it with each row of the table

         

        Then you add a column to this table using AddColumns