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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
DataMonkey101
Frequent Visitor

same day last year month to date charges

So I have this dax measure that returns the previous year's month total charges. However I just want it to return the month to date numbers. For example if today is December 21 2017, then I want to know the total charges from 12/1/16 - 12/21/16 not through 12/31/16.

 

Here is my measure that returns the same month last year's total instead of month to date:

 

Charges SDLY MTD = CALCULATE([Charges MTD], SAMEPERIODLASTYEAR(DatesforPivot_PostedDt[Date]))

 

 

1 ACCEPTED SOLUTION
DataMonkey101
Frequent Visitor

I figured it out. In case anyone else is looking for this here you go: 

 

CALCULATE(
[Total Charge's],
SAMEPERIODLASTYEAR(
DATESMTD('DatesforPivot_PostedDt'[Date])
),
FILTER(
ALL(DatesforPivot_PostedDt),
DatesforPivot_PostedDt[MonthOfYear] <= (MONTH(NOW())-1)
)
)+
CALCULATE(
[Total Charge's],
SAMEPERIODLASTYEAR(
DATESMTD('DatesforPivot_PostedDt'[Date])
),
FILTER(
ALL(DatesforPivot_PostedDt),
DatesforPivot_PostedDt[MonthOfYear] = MONTH(NOW())
&& 'DatesforPivot_PostedDt'[DayOfMonth] <= DAY(NOW())
)
)

View solution in original post

3 REPLIES 3
pawel1
Kudo Kingpin
Kudo Kingpin

 

one easy way is to filter the date < TODAY() 

 

Charges SDLY UpToYesterday=
    CALCULATE ( [Charges SDLY], FILTER('Date','Date'[Date]< TODAY()))

 

where [Charges SDLY] is the SAMEPERIODLASTYEAR measure

 

This formula is incorrect. It doesn't return the actual Same day last year, month to date numbers. It returns same day last year (minus 1 day) , year to date numbers.

DataMonkey101
Frequent Visitor

I figured it out. In case anyone else is looking for this here you go: 

 

CALCULATE(
[Total Charge's],
SAMEPERIODLASTYEAR(
DATESMTD('DatesforPivot_PostedDt'[Date])
),
FILTER(
ALL(DatesforPivot_PostedDt),
DatesforPivot_PostedDt[MonthOfYear] <= (MONTH(NOW())-1)
)
)+
CALCULATE(
[Total Charge's],
SAMEPERIODLASTYEAR(
DATESMTD('DatesforPivot_PostedDt'[Date])
),
FILTER(
ALL(DatesforPivot_PostedDt),
DatesforPivot_PostedDt[MonthOfYear] = MONTH(NOW())
&& 'DatesforPivot_PostedDt'[DayOfMonth] <= DAY(NOW())
)
)

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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