Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now
Hi
i have a data of the following( for example)
year | week in year | no. of people
2017 1 500
2018 1 300
2017 2 100
2018 2 50
*week in year is not derived from date but it based on some internal week counting in my organization
now - all i want to do is to put the current year vs previous year (with respeact to the same week in year no of people, meaning:
year | week in year | no of people current year | no of pepole previous year
2018 1 300 500
2018 2 50 100
so i could make a division calculation between those years with respect to this "week in year" coulmn ... but i can't make it! i tried with previousyear function but it works only if i omit this "week in year" coulmn ...
i also wish to know how can i calc "previous year" if it was with a numric format and not date format (which then i can't use the previousyear function)
thanks!
Elad
Solved! Go to Solution.
@ellevy try this measure for previous year
Prev Year and Week =
VAR __currentYear = MAX ( Table[Year] )
VAR __prevYear = __currentYear - 1
VAR __currentWeek = MAX ( Table[Week in Year] )
RETURN
CALCULATE (
SUM ( Table[Number of People] ),
Table[Year] = __currentYear,
Table[Week in Year] = __currentWeek
)
Check my latest blog post Year-2020, Pandemic, Power BI and Beyond to get a summary of my favourite Power BI feature releases in 2020
I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
⚡Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.⚡
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
@ellevy try this
VAR __currentYear = YEAR ( Table[DateColumn] )
VAR __prevYear = __currentYear - 1
Check my latest blog post Year-2020, Pandemic, Power BI and Beyond to get a summary of my favourite Power BI feature releases in 2020
I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
⚡Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.⚡
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
@ellevy not sure why it is not working for you, but works for me
Prev =
VAR __selectedYear = MAX ( PRow[Year] )
VAR __prevYear = __selectedYear - 1
VAR __selectedWeek = MAX ( PRow[Week] )
RETURN
CALCULATE (
SUM ( PRow[People] ),
PRow[Year] = __prevYear,
PRow[Week] = __selectedWeek
)
Check my latest blog post Year-2020, Pandemic, Power BI and Beyond to get a summary of my favourite Power BI feature releases in 2020
I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
⚡Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.⚡
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
@ellevy try this measure for previous year
Prev Year and Week =
VAR __currentYear = MAX ( Table[Year] )
VAR __prevYear = __currentYear - 1
VAR __currentWeek = MAX ( Table[Week in Year] )
RETURN
CALCULATE (
SUM ( Table[Number of People] ),
Table[Year] = __currentYear,
Table[Week in Year] = __currentWeek
)
Check my latest blog post Year-2020, Pandemic, Power BI and Beyond to get a summary of my favourite Power BI feature releases in 2020
I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
⚡Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.⚡
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Hi parry2k
this looks promise but it only return me the same no of people meaning :
year | week in year | no of people current year | no of pepole previous year
2018 1 300 300
2018 2 400 400
the "year" is in date format (so i think the year-1 is not working there....)
Ok i managed to make this work using :
CALCULATE (
SUM ( Table[Number of People] ),
Table[Year] = __PREVYEAR,
Table[Week in Year] = __currentWeek
)
and i used a numric date column that i have (meaning integer format and not date format)
how can i do the:
VAR __prevYear = __currentYear - 1
using a date format column ?
@ellevy , Create a column
Week Year = [Year]*100 + [Week]
Create a week year table with year, week, and Week Year table. Assume Date
Example measure
This Year = CALCULATE(sum('order'[Qty]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])))
Last Year = CALCULATE(sum('order'[Qty]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])-1))
For Week comparison you can create Week rank column in your table
Week Rank = RANKX(all('Date'),'Date'[Year Week],,ASC,Dense) //YYYYMM format
measures like
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)))
Power BI — Year on Year with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-ytd-questions-time-intelligence-1-5-e3174b39f38a
https://www.youtube.com/watch?v=km41KfM_0uA
Power BI — Week on Week and WTD
https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3
https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-La...
https://www.youtube.com/watch?v=pnAesWxYgJ8
Check out the October 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
113 | |
96 | |
91 | |
82 | |
69 |
User | Count |
---|---|
159 | |
125 | |
116 | |
111 | |
95 |