Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hi guys,
I have a long table of weekly shares (Share) of several products (SKU) in different regions (Region) as below with the yellow column names. I wish to add 3 calculated columns which present the previous week (-1 WEEK) share of the same product in the same region - same thing for the week before (-2 WEEK) and before that (-3 WEEK).
Please help.
Thanks
Solved! Go to Solution.
Hi, @akfir
You can try the following methods.
Column:
Rankweek = RANKX(FILTER('Table',[SKU]=EARLIER('Table'[SKU])&&[Region]=EARLIER('Table'[Region])),[Year_Week],,ASC)
-1 Week =
Var _week1=MAXX(FILTER('Table',[SKU]=EARLIER('Table'[SKU])&&[Region]=EARLIER('Table'[Region])&&[Rankweek]<EARLIER('Table'[Rankweek])),[Rankweek])
Return
CALCULATE(SUM('Table'[Share]),FILTER('Table',[SKU]=EARLIER('Table'[SKU])&&[Region]=EARLIER('Table'[Region])&&[Rankweek]=_week1))
-2 Week =
Var _week2=MAXX(FILTER('Table',[SKU]=EARLIER('Table'[SKU])&&[Region]=EARLIER('Table'[Region])&&[Rankweek]<EARLIER('Table'[Rankweek])-1),[Rankweek])
Return
CALCULATE(SUM('Table'[Share]),FILTER('Table',[SKU]=EARLIER('Table'[SKU])&&[Region]=EARLIER('Table'[Region])&&[Rankweek]=_week2))
-3 Week =
Var _week3=MAXX(FILTER('Table',[SKU]=EARLIER('Table'[SKU])&&[Region]=EARLIER('Table'[Region])&&[Rankweek]<EARLIER('Table'[Rankweek])-2),[Rankweek])
Return
CALCULATE(SUM('Table'[Share]),FILTER('Table',[SKU]=EARLIER('Table'[SKU])&&[Region]=EARLIER('Table'[Region])&&[Rankweek]=_week3))
Is this the result you expect?
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @akfir
You can try the following methods.
Column:
Rankweek = RANKX(FILTER('Table',[SKU]=EARLIER('Table'[SKU])&&[Region]=EARLIER('Table'[Region])),[Year_Week],,ASC)
-1 Week =
Var _week1=MAXX(FILTER('Table',[SKU]=EARLIER('Table'[SKU])&&[Region]=EARLIER('Table'[Region])&&[Rankweek]<EARLIER('Table'[Rankweek])),[Rankweek])
Return
CALCULATE(SUM('Table'[Share]),FILTER('Table',[SKU]=EARLIER('Table'[SKU])&&[Region]=EARLIER('Table'[Region])&&[Rankweek]=_week1))
-2 Week =
Var _week2=MAXX(FILTER('Table',[SKU]=EARLIER('Table'[SKU])&&[Region]=EARLIER('Table'[Region])&&[Rankweek]<EARLIER('Table'[Rankweek])-1),[Rankweek])
Return
CALCULATE(SUM('Table'[Share]),FILTER('Table',[SKU]=EARLIER('Table'[SKU])&&[Region]=EARLIER('Table'[Region])&&[Rankweek]=_week2))
-3 Week =
Var _week3=MAXX(FILTER('Table',[SKU]=EARLIER('Table'[SKU])&&[Region]=EARLIER('Table'[Region])&&[Rankweek]<EARLIER('Table'[Rankweek])-2),[Rankweek])
Return
CALCULATE(SUM('Table'[Share]),FILTER('Table',[SKU]=EARLIER('Table'[SKU])&&[Region]=EARLIER('Table'[Region])&&[Rankweek]=_week3))
Is this the result you expect?
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
This is the best solution (in my opinion) to fill the column with previous value
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
14 | |
10 | |
10 | |
9 | |
9 |
User | Count |
---|---|
20 | |
13 | |
12 | |
11 | |
8 |