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
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

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.

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.
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
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.