Forum Discussion
compounding values for dates
- Anonymous9 years ago
Bimster,
Firstly, unpivot your columns in your table, rename the blank column to "Stock".
Secondly, create a column using the DAX below.
Column = CALCULATE(SUM(Table[Value]),ALLEXCEPT(Table,Table[Stock]),Table[Attribute]<=EARLIER(Table[Attribute]))
Thirdly, create a Matrix visual as shown in the following capture.
Regards,
Lydia
Hi Bimster,
I assumed that your table is in a modular format with Date - Stock - Value (and you don't have a column for each date in your source table, if you do I would advise you to unpivot the columns to this format.
Add the measure below:
Stock_Value =
VAR min_date =
MIN ( Stocks[Date] )
RETURN
CALCULATE ( SUM ( Stocks[Value] ), Stocks[Date] = min_date )
+ CALCULATE ( SUM ( Stocks[Value] ), Stocks[Date] = min_date - 1 )This should give you what you want, so stock value is current date value + previous day value per stock.
Regards,
MFelix
- Bimster9 years agoFrequent Visitor
Hi MFelix,
The formula is good but I don't think it's quite right for what I need. The data for 03/06/2017 should be (for each stock) the figure calculated for 02/06/2017 (i.e. sum of 01/06/2017's value and 02/06/2017's value) added to the figure for 03/06/2017
01/06/2017 02/06/2017 03/06/2017 Stock 1 10 30 53 Stock 2 15 25 34 - Anonymous9 years agoNot applicable
Bimster,
Firstly, unpivot your columns in your table, rename the blank column to "Stock".
Secondly, create a column using the DAX below.
Column = CALCULATE(SUM(Table[Value]),ALLEXCEPT(Table,Table[Stock]),Table[Attribute]<=EARLIER(Table[Attribute]))
Thirdly, create a Matrix visual as shown in the following capture.
Regards,
Lydia - MFelix9 years agoSuper User
Try this change in the formula:
Stock_Value = VAR min_date = MIN ( Stocks[Date] ) RETURN CALCULATE ( SUM ( Stocks[Value] ), Stocks[Date] <= min_date )Regards,
MFelix