Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
I've this table that is incremented everyday with daily data. Now I would have a column in which I put the percentage difference between the values of "Positivi" column of the day with the values of one week earlier where possible(obviously for the first week it is impossible). How could I do this?
Thank you in advance
Solved! Go to Solution.
Hi @EffePi,
It sounds like a general requirement to get the difference from current records with records before one week. I'd like to suggest you add a variable to get the last value before one week and compare it with the current one.
Measure =
VAR currDate =
MAX ( Table[Date] )
VAR prevDate =
CALCULATE (
MAX ( Table[Date] ),
FILTER ( ALLSELECTED ( Table ), [Amount] <> BLANK () && [Date] <= currDate - 7 ),
VALUES ( Table[Category] )
)
VAR prevAmount =
CALCULATE (
SUM ( Table[Amount] ),
FILTER ( ALLSELECTED ( Table ), [Date] = prevDate ),
VALUES ( Table[Category] )
)
RETURN
DIVIDE ( SUM ( Table[Amount] ) - prevAmount, prevAmount )
Regards,
Xiaoxin Sheng
Hi @EffePi,
It sounds like a general requirement to get the difference from current records with records before one week. I'd like to suggest you add a variable to get the last value before one week and compare it with the current one.
Measure =
VAR currDate =
MAX ( Table[Date] )
VAR prevDate =
CALCULATE (
MAX ( Table[Date] ),
FILTER ( ALLSELECTED ( Table ), [Amount] <> BLANK () && [Date] <= currDate - 7 ),
VALUES ( Table[Category] )
)
VAR prevAmount =
CALCULATE (
SUM ( Table[Amount] ),
FILTER ( ALLSELECTED ( Table ), [Date] = prevDate ),
VALUES ( Table[Category] )
)
RETURN
DIVIDE ( SUM ( Table[Amount] ) - prevAmount, prevAmount )
Regards,
Xiaoxin Sheng
@EffePi , if you want to do using measure, you can do with date table and measure like example
This Day = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Date]=max('Date'[Date])))
Last Day = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Date]=max('Date'[Date])-1))
Last Day = CALCULATE(sum('order'[Qty]), previousday('Date'[Date]))
7 behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-7,DAy))
for week you need these columns in date table
Week Rank = RANKX(all('Date'),'Date'[Week Start date],,ASC,Dense)
measures
This Week = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])))
Last Week = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])-1))
Last year Week= CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=(max('Date'[Week Rank]) -52)))
To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
112 | |
100 | |
76 | |
74 | |
49 |
User | Count |
---|---|
146 | |
108 | |
106 | |
90 | |
62 |