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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Osama14
Frequent Visitor

Show Pervious Year and Previous Month values

Hi, I am stuck in getting the value for the previous year and the previous month.

My Data set is number of KPI values added every Month, I want to create a measure that compares the total of the previous year against the total of this year or Month

Osama14_0-1635966929597.png

I am putting the KPI title in the  Filter and month name and the actual value of that KPI in the table visual. Note that I have a calendar table created in M query called Date Dimension.

I have tried multiple dax formulas but not been able to get it right and it shows blank

Previous = CALCULATE(SUM('KPI'[Actual_Value]),PREVIOUSMONTH('Date Dimension'[Date].[Date]))

Previous = CALCULATE(SUM('KPI'[Actual_Value]),PREVIOUSYear ('Date Dimension'[Date].[Date]))

Osama14_1-1635966929715.png


Appreciate you help

3 REPLIES 3
v-robertq-msft
Community Support
Community Support

Hi, 

According to the DAX formula and output pictures you posted, I think that the problem may exist in the table relationship between the calendar table with your main table. I suggest you to go to the relationship page to check if the filter direction is both and if the relationship is enabled.

If you still have a problem with this, you can post some sample data(without sensitive data) so that we can help you to find out the root cause.

How to Get Your Question Answered Quickly 

 

Thank you very much!

 

Best Regards,

Community Support Team _Robert Qin

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

lbendlin
Super User
Super User

You don't specify if you are using measures or calculated columns. Beware of the filter context.

 

Note:  You may want to use DATEADD() instead, as the other functions (including SAMEPERIODLASTYEAR) are mostly syntax sugar.

Hi, I am creating a measure - I have tried the below but it's not working with all KPI's 

 

PREVLSV =
var _curYear = MAX('Date Dimension'[Year])
RETURN
CALCULATE(SUM('KPI'[Actual_Value]), FILTER(ALL('Date Dimension'), 'Date Dimension'[Year] = _curYear -1))

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.

Top Solution Authors