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

Previous year previous month not calculating correctly

Hi

 

I have this formula but it is not calculating the amounts correctly - please assist- it is for previous year previous month

 

CommissionPYPM =

VAR CurrentMonth = MONTH(TODAY())

VAR CurrentYear = YEAR(TODAY())

VAR StartDate = DATE(CurrentYear -1, CurrentMonth, -1)

VAR EndDate = EOMONTH(StartDate, 0)

 

RETURN

CALCULATE(

    SUM(vw_TTV[Commission]),

    FILTER(

        ALL(DimDate[DateFull]),

        DimDate[DateFull] >= StartDate && DimDate[DateFull] <= EndDate

    )

)
1 ACCEPTED SOLUTION
JoeBarry
Solution Sage
Solution Sage

Hi @NadiaLR1234 

 

For previous year please try the following.

 

Create a base measure  

TotalCom = SUM(vw_TTV[Commission])

Create a YTD 

ComYTD = TOTALYTD([TotalCom], DIMDate[DateFull])

 

For Previous Year

ComPY = CALCULATE([ComYTD], DATEADD(DimDate[DateFull], -1, YEAR))

 

For Previous Month change the last two measures to TOTALMTD in the first of the two and the Interval YEAR to MONTH in the 2nd measure of the two

 

Thanks

Joe

 

If this post helps, then please Accept it as the solution

 

View solution in original post

1 REPLY 1
JoeBarry
Solution Sage
Solution Sage

Hi @NadiaLR1234 

 

For previous year please try the following.

 

Create a base measure  

TotalCom = SUM(vw_TTV[Commission])

Create a YTD 

ComYTD = TOTALYTD([TotalCom], DIMDate[DateFull])

 

For Previous Year

ComPY = CALCULATE([ComYTD], DATEADD(DimDate[DateFull], -1, YEAR))

 

For Previous Month change the last two measures to TOTALMTD in the first of the two and the Interval YEAR to MONTH in the 2nd measure of the two

 

Thanks

Joe

 

If this post helps, then please Accept it as the solution

 

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.