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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
Florcita
Regular Visitor

Problem with a measure to compare values

Hi guys! How are you? I need some help!

I dont know how to calculate a DAX measure. I tried several ways and failed to do it.

 

On one hand, i have a measure that cumulatively summarizes "operation fee" (and indicator that calculates the accumulated income for the current month) with this DAX:

 

Fee Mensual = CALCULATE(sum(TradeOrder[operationFee]))

 

And, on the other hand, i need to calculate that accumulated "operation fee" for the same date of the previous month. Example: if i do it today, i compare the accumulated income for October with the accumulated income until September the 8th.

The measure i used to calculate the second indicator es:

 

AcumuladoMovilMesAnterior = CALCULATE(SUM(TradeOrder[operationFee]), FILTER(Dim_Calendario,

Dim_Calendario[Date] <= EOMONTH(MAX(Dim_Calendario[Date]), -1)
&& DAY(Dim_Calendario[Date]) <= DAY(MAX(Dim_Calendario[Date])) ) )

But for some reason, it doesnt return the correct value.

 

Hope you can help me with this!

Thanks

1 ACCEPTED SOLUTION
audreygerred
Super User
Super User

Hi! You can use the below DAX:

AmountLastMonthToDate =
VAR TodayDate = TODAY()
VAR StartOfCurrentMonth = DATE(YEAR(TodayDate), MONTH(TodayDate), 1)
VAR EndOfCurrentMonth = TodayDate
VAR StartOfLastMonth = EOMONTH(TodayDate, -2) + 1
VAR EndOfLastMonth = EOMONTH(TodayDate, -1)
VAR LastMonthToDate = DATESBETWEEN(
    'YourDateTable'[Date],
    StartOfLastMonth,
    StartOfLastMonth + DAY(TodayDate) - 1
)
RETURN
CALCULATE(
    [Operation Fee,
    LastMonthToDate
)
 
I created the below sample data:
audreygerred_1-1728400781264.png

Then, I added the date to filters on this page (you could also use all pages) and set it to relative date for in this month: 

audreygerred_2-1728400830320.pngaudreygerred_3-1728400891782.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

1 REPLY 1
audreygerred
Super User
Super User

Hi! You can use the below DAX:

AmountLastMonthToDate =
VAR TodayDate = TODAY()
VAR StartOfCurrentMonth = DATE(YEAR(TodayDate), MONTH(TodayDate), 1)
VAR EndOfCurrentMonth = TodayDate
VAR StartOfLastMonth = EOMONTH(TodayDate, -2) + 1
VAR EndOfLastMonth = EOMONTH(TodayDate, -1)
VAR LastMonthToDate = DATESBETWEEN(
    'YourDateTable'[Date],
    StartOfLastMonth,
    StartOfLastMonth + DAY(TodayDate) - 1
)
RETURN
CALCULATE(
    [Operation Fee,
    LastMonthToDate
)
 
I created the below sample data:
audreygerred_1-1728400781264.png

Then, I added the date to filters on this page (you could also use all pages) and set it to relative date for in this month: 

audreygerred_2-1728400830320.pngaudreygerred_3-1728400891782.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.