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
powerrdl
Helper I
Helper I

Month on Month value for This Year and Previous Year

Untitled1.png

 

The above image shows a matrix with 'Month' in Rows, 'Year' in Columns and 'Policy Count' in Values.

 

I need to write DAX Expressions for 'Policy Count TY' and 'Policy Count PY' such that I get same output when I create a matrix with just 'Month' in Rows and the two Expressions, and no filter applied on Year Slicer. Expressions should be able to take Max(Year) and Max(Year)-1.

 

Further, if I select, say, Nov in Month Slicer, the Matrix is required to show all months upto Nov and not just Nov. Values against each month are required as 'for the month' and not cumulative.

 

I have tried various options but no luck. I am either getting 'Contiguous Dates' error or getting cumulative output

 

Thanks

1 ACCEPTED SOLUTION
Eric_Zhang
Employee
Employee

@powerrdl

You can see a workaround by using two extra auxiliary tables. See more details in the attached pbix file.

By the way, may I know any reason not using a Matrix?

 

Capture.PNGCaptur2e.PNG

View solution in original post

3 REPLIES 3
Eric_Zhang
Employee
Employee

@powerrdl

You can see a workaround by using two extra auxiliary tables. See more details in the attached pbix file.

By the way, may I know any reason not using a Matrix?

 

Capture.PNGCaptur2e.PNG

Hi @Eric_Zhang,

 

Many thanks for your solution ! Its a cool workaround !!

 

Regards

Rameen

Anonymous
Not applicable

Your life (or at least data model) will improve if you add a calendar table.

http://tinylizard.com/power-bi-date-table/ 

 

This will allow :

  Policy Count PY := CALCULATE([Policy Count], SAMEPERIODLASTYEAR(Dates[Date]))

 

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.