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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
agustira97
Frequent Visitor

Return exact value from same month but from last year.

I've already make an calculated table in visual studio and it look like this.

agustira97_0-1674719513592.png

CountRows is created using CalculatedColumn where it will count how many rows with the same year and month.
I need to show not just exact same years and month, but also last year and last 2 year in my visualization.


How to make dax measure to show last year and last 2 year without using aggregate like sum? Because CountRows already counted.

I want when my filter year = 2022 ; month = 12 it will show value from 2021-12 for my last year visualisation.

*sorry for my bad english, hope you all can understand.

2 REPLIES 2
IoannisPhilip
Advocate II
Advocate II

Hi @agustira97 ,
you could try using the following:

= CALCULATE(SUM(countrows]), SAMEPERIODLASTYEAR(DateTime[DateKey]))

the SUM() will not alternate the aggregation you expect.
For 2 years, you can try to use instead :

 DATEADD(dates, -2, year)

 Feel free to adjust the period or the timeframe you want.

I hope that was useful.

Thank you for your answer... So I made a new calculated column name 'FullDate' that return date format.
I've also already try run just dateadd, and yeah I got the date that I want.
But when I used it with

CALCULATE(SUM(CalculatedTable1[CountRows]), DATEADD(CalculatedTable1[Full_Date], -1, year)) , the result in my PBI is blank? why?

agustira97_0-1675064464662.png

 

Helpful resources

Announcements
ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.