Forum Discussion
franpimed
7 years agoFrequent Visitor
Create new column with the previous period value
Hello, I'm new in power bi and I'm trying to create a new column that allows me to get the value of the previous month, but I have several columns in the data and I don“t know how to perform the fil...
- Anonymous7 years ago
You can use the following code to generate a new column:
Column = VAR __CurrentPeriod = Test[PERIOD D/M/YY] var __CurrentCountry = Test[COUNTRY] var __CurrentProduct = Test[PRODUCT] var __CurrentActivity = Test[ACTIVITY] RETURN CALCULATE( SUM( Test[CANTIDAD] ), FILTER( Test, Test[COUNTRY] = __CurrentCountry && Test[PRODUCT] = __CurrentProduct && Test[ACTIVITY] = __CurrentActivity && __CurrentPeriod = NEXTMONTH(Test[PERIOD D/M/YY]) ) )
Anonymous
7 years agoNot applicable
You can use the following code to generate a new column:
Column =
VAR __CurrentPeriod = Test[PERIOD D/M/YY]
var __CurrentCountry = Test[COUNTRY]
var __CurrentProduct = Test[PRODUCT]
var __CurrentActivity = Test[ACTIVITY]
RETURN
CALCULATE(
SUM( Test[CANTIDAD] ),
FILTER(
Test,
Test[COUNTRY] = __CurrentCountry
&& Test[PRODUCT] = __CurrentProduct
&& Test[ACTIVITY] = __CurrentActivity
&& __CurrentPeriod = NEXTMONTH(Test[PERIOD D/M/YY])
)
)- franpimed7 years agoFrequent Visitor
Amazing. Works perfectly. Thanks for your great solution.