Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
bmed
New Member

Get Last year Amount

Hi All,

I am creating a report and the DS is SQL Server table. It is a simple table with 3 columns YEAR,REGION,AMOUNT.

I have a report with a slicer as YEAR and a score card showing the amount (filter based on the visual tied to REGION). My ask is I want another score card next to the one I have and should dispaly PREVIOUS YEAR AMOUNT. For example if I select the slicer to have 2019, my first score card should show Amount for 2019, the new one should show for 2018, is that possible? I tried using "SAMEPERIODLASTYEAR" , but that needs a DATE, but my table is aggregated by YEAR. Please advise.

Thanks

5 REPLIES 5
mhossain
Solution Sage
Solution Sage

@bmed 

 

Try to create a measure like below:

PreviousYearAmount =
CALCULATE(
SUM('Table'[AMOUNT]),
ALL('Table'[YEAR]),
'Table'[YEAR]=VALUES('Table'[YEAR])-1)
 
 
And drag this measure to your second card

@mhossain Thanks,

I am getting a syntax error "Parameter is not the correct Type"

Capture.PNG

@bmed 

 

Seems you missed paranthesis, see below

VALUES('Billing (2)'[Service Year])-1

@mhossain 

Now when i drag the New Measure into the score card I get the following message

Error Message:

MdxScript(Model) (8, 1) Calculation error in measure 'Billing (2)'[PreviousYearAmount]: DAX comparison operations do not support comparing values of type Text with values of type Number. Consider using the VALUE or FORMAT function to convert one of the values.

@bmed 

Convert this column "[PreviousYearAmount]" to whole number in powerquery probably, error shows that this is not a number column.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.