Forum Discussion
HOrakova
1 year agoHelper I
Diff between selected and previous period
Hi Experts, I've closed the previous one as solved, but when I add all filter the formula is not working again. So: I have [Date] column with only start of the week dates in it. I need to calculate...
- 1 year ago
Hi v-kpoloju-msft and techies ,
I managed to get the measure to work the way I needed it to:
Previous Period Value =VAR PeriodType = MAX('Period'[Period Type])VAR PeriodsBack = SELECTEDVALUE('No of Periods'[Value])VAR PrevRank = [Switch MAX Period Rank] - PeriodsBackVAR CurrentMarket = SELECTEDVALUE('data'[Market])VAR CurrentCategory = SELECTEDVALUE('data'[Category])VAR CurrentBrand = SELECTEDVALUE('data'[Brand])RETURNIF(ISBLANK(PrevRank),BLANK(),CALCULATE([Switch KPIs],FILTER(ALL('data'),SWITCH(PeriodType,"Week", 'data'[Wave] = PrevRank,"Month", 'data'[Month Rank] = PrevRank,"Quarter", 'data'[Quarter Rank] = PrevRank,"Year", 'data'[Year Rank] = PrevRank) &&'data'[Market] = CurrentMarket &&'data'[Category] = CurrentCategory &&'data'[Brand] = CurrentBrand &&NOT(ISFILTERED('data'[Age])) &&NOT(ISFILTERED('data'[Children])))))
Probably there were too many unknowns and I didn't explain things the right way, but I really appreciate your time.
Thanks a lot!
HO
techies
1 year agoSuper User
Hi HOrakova please try this previous period value
Previous Period Value =
VAR SelectedDate = MAX(data[Date])
VAR PreviousDate = CALCULATE(
MAX(data[Date]),
ALL(data),
data[Date] < SelectedDate
)
RETURN
CALCULATE(
SUM(data[Value]),
ALL(data),
data[Date] = PreviousDate
)
HOrakova
1 year agoHelper I
Hi techies ,
How will look your formula when I use parameter instead of [Date]?
- techies1 year agoSuper UserPrevious Period Value =VAR SelectedDate = SELECTEDVALUE('Date Parameter'[Date Selection])VAR PreviousDate =CALCULATE(MAX('data'[Date]),ALL('data'),'data'[Date] < SelectedDate)RETURNCALCULATE(SUM('data'[Value]),ALLSELECTED('data'),'data'[Date] = PreviousDate)
- HOrakova1 year agoHelper I
Unfortunately it is not working.
I uploaded a sanitized copy of my pbix here:
https://we.tl/t-pbH4A7Azfv
Hope this helps to understand my case.Best Regards!
- techies1 year agoSuper User
Hi, i would suggest using a date table?