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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
AThakur1
Frequent Visitor

Issue with TotalMTD Calculation.

Hi, I am trying to calcuate MTD Consumption & using below dax. 

 

MTDConsumption = TOTALMTD(SUM(Consumption[Qty Consumed]),Consumption[Consumption Date])
 
In below image selected item was last consumed on 13 March'25.However its showing MTD consumption 110. 
 
AThakur1_0-1746009322814.png

Can you someone please assist and let me know what I am doing wrong?

1 ACCEPTED SOLUTION
v-echaithra
Community Support
Community Support

Hi @AThakur1 ,

Try the below DAX,

MTD Consumption =
var_CurrentMonth = MONTH(TODAY())
var_CurrentYear = YEAR(TODAY())
var_Hasdatathismonth =
CALCULATE(COUNTROWS(Consumption),
FILTER(
Consumption,
MONTH(Consumption[Consumption Date]) = _CurrentMonth &&
YEAR(Consumption[Consumption Date]) = _CurrentYear
)
) > 0
RETURN
IF(Hasdatathismonth, TOTALMTD(SUM(Consumption[Qty Consumed]), 'Date'[Date]),BLANK()
It checks if the item has any consumption in April, and only then it shows MTD otherwise shows blank.

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks and Regards,
Chaithra E.

 

 

View solution in original post

7 REPLIES 7
v-echaithra
Community Support
Community Support

Hi @AThakur1 ,

We wanted to kindly follow up to check if the solution provided for the issue worked? or Let us know if you need any further assistance?
If our response addressed, please mark it as Accept as solution and click Yes if you found it helpful.

 

Regards,
Chaithra.

v-echaithra
Community Support
Community Support

Hi @AThakur1 ,

May I ask if you have gotten this issue resolved?

 

If it is solved, please mark the helpful reply or share your solution and accept it as solution, it will be helpful for other members of the community who have similar problems as yours to solve it faster.

 

Regards,
Chaithra.

v-echaithra
Community Support
Community Support

Hi @AThakur1 ,

We wanted to kindly follow up to check if the solution provided for the issue worked? or Let us know if you need any further assistance?
If our response addressed, please mark it as Accept as solution and click Yes if you found it helpful.

 

Regards,
Chaithra.

v-echaithra
Community Support
Community Support

Hi @AThakur1 ,

Try the below DAX,

MTD Consumption =
var_CurrentMonth = MONTH(TODAY())
var_CurrentYear = YEAR(TODAY())
var_Hasdatathismonth =
CALCULATE(COUNTROWS(Consumption),
FILTER(
Consumption,
MONTH(Consumption[Consumption Date]) = _CurrentMonth &&
YEAR(Consumption[Consumption Date]) = _CurrentYear
)
) > 0
RETURN
IF(Hasdatathismonth, TOTALMTD(SUM(Consumption[Qty Consumed]), 'Date'[Date]),BLANK()
It checks if the item has any consumption in April, and only then it shows MTD otherwise shows blank.

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks and Regards,
Chaithra E.

 

 

AThakur1
Frequent Visitor

(Reposting.. not able to see my previous reply).

 

Thank you for the reply.

 

Below it the desired output. 

AThakur1_1-1746183117819.png

 

Tried both dax & they are calculating sum from prevoius months(whichever last date/month available) for highlited yellow items. As data for these items not avilabel for the month of Apr'25 in the dataset. 

 

Its same for MTD & YTD results, they calculating result considering last available date, if data for current month/year not available. However, total for both YTD/MTD is correct.

Data is coming from three table (item number is comman in all tables), 

1-Item master

2-Stock.

3-consumption. 

 

Have also tried creating calander & conneting date but same result. 

AThakur1_2-1746183584145.png

MTD Consumption = TOTALMTD(SUM(Consumption[Qty Consumed]),'Date'[Date])

 

 

 

 

anilelmastasi
Super User
Super User

Hello @AThakur1 ,

 

TOTALMTD works based on the current filter context. So, if your item isn't actively filtered in a visual or slicer, Power BI computes the total for all items for the month-to-date. You need to filter the calculation by item if you're expecting it per item, or clarify the context in your measure.

 

If you want to compute MTD for a selected item only:

MTDConsumption =
CALCULATE(
TOTALMTD(
SUM(Consumption[Qty Consumed]),
Consumption[Consumption Date]
),
ALLSELECTED(Consumption[Item]) -- or filter by a specific item
)

 

If this solved your issue, please mark it as the accepted solution.

 

@anilelmastasi ,Thank you for reply!

 

Below is the desired output table.However, both dax calcuating total from the previous months (whichever is the last available month )for the highlited yellow rows, as these items not consumed in current month their data not availabel for Apr'25 in the dataset.

 

If i check MTD/YTD total it's correct, but in rows its cehcking data for all the items from item master.

 

Bleow data is coming from three tables:

Item no from item master.

Stock from Stock & consumption from consumption. 

 

AThakur1_0-1746179304197.png

 

Also,created calander used below formula but same result. :

AThakur1_1-1746180407260.png

MTD Consumption = TOTALMTD(SUM(Consumption[Qty Consumed]),'Date'[Date])
.

 

 

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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