Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more
Solved! Go to Solution.
Hi @Anonymous
Create a new table with this formula
Table = VALUES(Sheet2[Year])
Sheet2 is the table as your example data.
Don't connect this "Table" with Sheet2, it means the two tables should have no relationship.
Add Table[year] in the slicer, create measures in "Sheet2".
Selected year = SELECTEDVALUE('Table'[Year])\ CY = CALCULATE(SUM(Sheet2[Sales]),ALLSELECTED(Sheet2)) PY = CALCULATE(SUM(Sheet2[Sales]),FILTER(ALL(Sheet2),[Year]=[Selected year]-1))
Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous
Create a new table with this formula
Table = VALUES(Sheet2[Year])
Sheet2 is the table as your example data.
Don't connect this "Table" with Sheet2, it means the two tables should have no relationship.
Add Table[year] in the slicer, create measures in "Sheet2".
Selected year = SELECTEDVALUE('Table'[Year])\ CY = CALCULATE(SUM(Sheet2[Sales]),ALLSELECTED(Sheet2)) PY = CALCULATE(SUM(Sheet2[Sales]),FILTER(ALL(Sheet2),[Year]=[Selected year]-1))
Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hello @v-juanli-msft
Thanks for your help. I applied your solution and it's working perfectly with a minor chage to CY.
The CY measure
CY = CALCULATE(SUM(Sheet2[Sales]),ALLSELECTED(Sheet2))
is giving total sales of all years. So, I changed it to
CY = CALCULATE(SUM(Sheet2[Sales]),FILTER(ALL(Sheet2),Sheet2[Year]=Sheet2[Selected year]))
Hello @v-juanli-msft,
How can I calculate YTD Sales for CY and PY based on year selected?
Regards,
James Arthur
Hi @Anonymous
Does the previous measure not help?
How about this DAX function TOTALYTD which evaluates the year-to-date value of the expression in the current context?
Best Regards
Maggie
Check out the April 2025 Power BI update to learn about new features.
Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.
User | Count |
---|---|
107 | |
68 | |
48 | |
47 | |
44 |