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.
Can anyone help explain why the Amount_PY measure is not returning the correct value in the Full Year scenario below.
It is summing up amount across all years but I'm just not able to figure out why.
DEFINE
MEASURE __Metrics[Amount] =
SWITCH (
SELECTEDVALUE ( __Period[Period Name] ),
"Month",
CALCULATE (
SUM ( Financials[Accounting Currency Amount Signed] ),
DATESMTD ( 'AccountingCalendar'[Date] )
),
"Year-To-Date",
CALCULATE (
SUM ( Financials[Accounting Currency Amount Signed] ),
DATESYTD ( 'AccountingCalendar'[Date] )
),
"Full Year",
CALCULATE (
SUM ( Financials[Accounting Currency Amount Signed] ),
ALLEXCEPT ( AccountingCalendar, AccountingCalendar[Year] )
),
SUM ( Financials[Accounting Currency Amount Signed] )
)
MEASURE __Metrics[Amount_AC] =
CALCULATE ( [Amount], Scenarios[Scenario Type] = "Actuals" )
MEASURE __Metrics[Amount_PY] =
CALCULATE ( [Amount_AC], SAMEPERIODLASTYEAR ( AccountingCalendar[Date] ) )
EVALUATE
SUMMARIZECOLUMNS (
AccountingCalendar[Year],
AccountingCalendar[Calendar Month],
__Period[Period ID],
__Period[Period Name],
TREATAS ( { "Latest" }, AccountingCalendar[Month Type] ),
TREATAS ( { 2022, 2023, 2024 }, AccountingCalendar[Year] ),
"Amount_AC", [Amount_AC],
"Amount_PY", [Amount_PY]
)
ORDER BY
AccountingCalendar[Year] ASC,
__Period[Period ID] ASC
Note: The Month Type essentially filters the latest completed month within each year.
Solved! Go to Solution.
@VickyDev18 , you also need a switch for the previous measure
Please refer example measure, which you have use in Switch for PY
This will work for the month and the same period
Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),SAMEPERIODLASTYEAR('Date'[Date]))
Last year ytd
Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-1,Year),"12/31"))
Last year full
Last year Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(ENDOFYEAR(dateadd('Date'[Date],-1,Year)),"12/31"))
Last Year full = CALCULATE(SUM(Sales[Sales Amount]),previousyear('Date'[Date]))
Time Intelligence, Part of learn Power BI https://youtu.be/cN8AO3_vmlY?t=27510
Time Intelligence, DATESMTD, DATESQTD, DATESYTD, Week On Week, Week Till Date, Custom Period on Period,
Custom Period till date: https://youtu.be/aU2aKbnHuWs&t=145s
@VickyDev18 , you also need a switch for the previous measure
Please refer example measure, which you have use in Switch for PY
This will work for the month and the same period
Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),SAMEPERIODLASTYEAR('Date'[Date]))
Last year ytd
Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-1,Year),"12/31"))
Last year full
Last year Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(ENDOFYEAR(dateadd('Date'[Date],-1,Year)),"12/31"))
Last Year full = CALCULATE(SUM(Sales[Sales Amount]),previousyear('Date'[Date]))
Time Intelligence, Part of learn Power BI https://youtu.be/cN8AO3_vmlY?t=27510
Time Intelligence, DATESMTD, DATESQTD, DATESYTD, Week On Week, Week Till Date, Custom Period on Period,
Custom Period till date: https://youtu.be/aU2aKbnHuWs&t=145s
Thanks @amitchandak . Was able to get it to work after adding SWITCH for the PY measure as well.
However, curious to know why just using SAMEPERIODLASTYEAR does not work in my orginal PY measure.
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 |
---|---|
11 | |
9 | |
8 | |
8 | |
7 |
User | Count |
---|---|
14 | |
12 | |
11 | |
10 | |
9 |