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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
admin_xlsior
Post Prodigy
Post Prodigy

Create fixed measure

Hi guys,

 

I'm trying to create a measure, Total sales last year divide by 12, 

I already have my Total Sales measure, so I think I just add new measure and use the function SAMEPERIODLASTYEAR like this : 

Total Sales LY = CALCULATE([Total sales], SAMEPERIODLASTYEAR('Date'[datekey]))

and then another measure for the division :

MyMeasure = DIVIDE([Total sales LY], 12, 0)

 

But it turns out if I display my report monthly, it divided by 12 from my Total sales in its individual months, so lets say I total sales LY, MyMeasure ( x ) will show like below :

 Total salesx
Jan-181200100
Feb-182400200
Mar-181200100
Apr-182400200
May-183600300
Jun-183600300
Jul-181200100
Aug-182400200
Sep-1860050
Oct-1860050
Nov-181200100
Dec-182400200

 

This is not what I want, since all I want is just the total of the sales amount then divide by 12. In that table, the total is 22,800, So I want my measure to display 22,800 / 12 all the time which is 1,900

 

So I thought I can't use the 1st method. Then I create new measure like below :

MyMeasure per month =
VAR nTotal_Sales_LY = CALCULATE(SUMX('SalesFact', 'SalesFact'[SalesAmount]),
DATESBETWEEN('Date'[DateKey], STARTOFYEAR(SAMEPERIODLASTYEAR('Date'[DateKey])), ENDOFYEAR(SAMEPERIODLASTYEAR('Date'[DateKey])))
)
RETURN DIVIDE(nTotal_Sales_LY , 12, 0)

 

It has no syntax error, but when I use it, it shows error:

image.png

 

 

Something wrong with my measure ? 

What is the correct way to have fixed value ?

 

Thanks,

 

 

 

 

 

 

 

2 REPLIES 2
Ashish_Mathur
Super User
Super User

Hi,

Create a Calendar Table and build a relationship from the Date column of your Table to the Date column of your Calendar Table.  In the Calendar Table, write formulas to extract YEar and Month.  To your visual, drag Year and Month from the Calendar Table.  Try this measure

=CALCULATE([Total Sales],DATESBETWEEN(Calendar[Date],DATE(YEAR(MIN(Calendar[Date]))-1,1,1),DATE(YEAR(MIN(Calendar[Date]))-1,12,31)))/12

or

=CALCULATE([Total Sales],PREVIOUSYEAR(Calendar[Date]))/12


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
OwenAuger
Super User
Super User

@admin_xlsior 

The PARALLELPERIOD function should be useful for what you are trying to do.

PARALLELPERIOD lets you expand the date filter to complete months, quarters or years.

 

For example, you could write this measure to return sales for the entire current year:

 

Total Sales Current Year =
CALCULATE(
    [Total sales],
    PARALLELPERIOD ( 'Date'[datekey], 0, YEAR )
)

 

Then any of these measures are variations that return sales for the entire previous year

Total Sales LY =
CALCULATE(
    [Total sales],
    SAMEPERIODLASTYEAR ( PARALLELPERIOD ( 'Date'[datekey], 0, YEAR ) )
)

 

Total Sales LY =
CALCULATE(
    [Total sales],
    PARALLELPERIOD ( 'Date'[datekey], -1, YEAR )
)

 

Total Sales LY =
CALCULATE(
    [Total Sales Current Year],
    SAMEPERIODLASTYEAR ( 'Date'[datekey] )
)

Does that help?

 

Regards,

Owen


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Top Solution Authors