Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hi everyone
I want to sum the stock value before 2 years from the selected year , for example if the selected year is 2024 i want to get stock in 2022 and if the selected year is 2023 I want to get 2021 value and so on
I useed these measures to calculate the selected year and last year
this yearstock =
last yearstock =
Solved! Go to Solution.
Hi @Wadda7AboUdai ,
Thanks for reaching out!
I understand you want ignore the filtering of the month. My workaround is to create a separate table contains years.
I've created a sample for your reference:
Sample data:
1.Create a separate year table.
2.Create a measure to return previous data and ignore month filtering.
Previousyear = CALCULATE(SUM('Table'[Value]),FILTER(ALL('Table'),YEAR([Date])=SELECTEDVALUE('Table (2)'[Year])-1))
Thisyear:
Thisyear=CALCULATE(SUM('Table'[Value]),FILTER(ALL('Table'),YEAR([Date])=SELECTEDVALUE('Table (2)'[Year])))
You can check more details by downloading the attachment.
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@Anonymous thank you for your help
Hi @Wadda7AboUdai ,
Thanks for reaching out!
I understand you want ignore the filtering of the month. My workaround is to create a separate table contains years.
I've created a sample for your reference:
Sample data:
1.Create a separate year table.
2.Create a measure to return previous data and ignore month filtering.
Previousyear = CALCULATE(SUM('Table'[Value]),FILTER(ALL('Table'),YEAR([Date])=SELECTEDVALUE('Table (2)'[Year])-1))
Thisyear:
Thisyear=CALCULATE(SUM('Table'[Value]),FILTER(ALL('Table'),YEAR([Date])=SELECTEDVALUE('Table (2)'[Year])))
You can check more details by downloading the attachment.
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
User | Count |
---|---|
14 | |
9 | |
7 | |
7 | |
6 |
User | Count |
---|---|
21 | |
11 | |
10 | |
10 | |
8 |