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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
enocperez
Frequent Visitor

Calculates MTD with New Measure

I want to get a New Measure and I get an errros all the time what am I doing.

 

Sales MTD =CALCULATE( [Sales], PARALLELPERIOD('Item Sales'[Date Of Business], -1,MONTH))

 

Sales MTD - Issues.jpg

5 REPLIES 5
MattAllington
Community Champion
Community Champion

Sales is a column. You have not told Power Pivot how to aggregate the column.  Also you should never refer to a column without specifying the table name. So replace [Sales] with    sum(TableName[Sales])

 

replace TableName with the actual name of your table. 



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.

Ok I have made the update and still I get an issues with the Calculation.  

 

Sales MTD - Issues -1.jpg

 

 

Hi @enocperez,

 

In DAX, to calculate the MTD value, we can use DATESMTD() to assign a MTD dates row set in filter within CALCULATE() funciton. And we can only pass one column as argument in SUM() function. In this scenario, you just need to SUM the sales column with a MTD row set filter within CALCULATE():

 

MTD:=CALCULATE(SUM('Item Sales'[Sales]), DATESMTD('Date Table'[FullDate]))

 

Reference:

DATESMTD Function (DAX)

 

Regards,

 

 

You need to read the error messages you get. They normally tell you what the problem is. Your error says there are too many arguments for the sum function. That is a hint that you have missed a round bracket after the square bracket in sum. 

 

Also, by the way, the PARALLELPERIOD looks wrong too.  I would first write current MTD using TOTALMTD

Total Sales MTD = TOTALMTD(sum('item sales'[sales]),calendar[date])

and then a version for MTD prior period like this 

=calculate([Total Sales MTD],datesadd(calendar[date],-1,month))

 

as Sean said, you also need a calendar table.  You can read about that in my knowledge base http://exceleratorbi.com.au/power-pivot-calendar-tables/



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.
Sean
Community Champion
Community Champion

@enocperez

Do you have a Date table?

 

MTD = TOTALMTD([MeasureName], CalendarTable[Date])
MTD2 = Calculate([MeasureName],DATESMTD(CalendarTable[Date]))

 

You can also do YTD and QTD with these just change where it says MTD to either one...

 

Let me know if they work for you.

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 MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.