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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
monojchakrab
Resolver III
Resolver III

Totalling error in MTD sales

Hi All,

 

Here is a screenshot of the dashboard which is showing wrong totals :

 

Screenshot (11).png

The total in the MTD column for Feb is wrongly being calculated (the actual number if added from the base files shud be 2.8 L).

The measure is used is as follows (which btw is working perfectly for all other months ) :

monojchakrab_0-1678113626256.png

The total sales is nothing but the value column summed.

The [date] column of the Date Table is linked to the Date column of the fact table and is returning the exact same number of rows as the source files.

Could there be something specific going wrong with Feb?

Any help much appreciated

Thanks

 

4 REPLIES 4
amitchandak
Super User
Super User

@monojchakrab , Try like

 

LMTD QTY forced=
Var _Maxdate = MAX('Date Table'[Date])
var _max = date(year(_Maxdate),month(_Maxdate)-1,day(_Maxdate))
return
if(max('Date'[Date])<=_max, CALCULATE(Sum('order'[Qty]),DATESMTD(dateadd('Date'[Date],-1,year)),'Date'[Date]<=_max), blank())
//OR
//CALCULATE(Sum('order'[Qty]),DATESMTD(dateadd('Date'[Date],-1,year)),'Date'[Date]<=_max)
//TOTALMTD(Sum('order'[Qty]),dateadd('Date'[Date],-1,year),'Date'[Date]<=_max)

 

Comments are alternate options

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak - Amit, actually, surprisingly, the LMSP (last month same period), actually returns the right figure.

Its the MTD and only for the month of Feb, where there is a problem.

If there something else I need to look at? I dont think the measure is a problem as the same measures work fine for all other months.

Anyways - thank you for being in my corner

amitchandak
Super User
Super User

@monojchakrab , Is LMSP Value is same as Total Sales ?

 

if yes

Can you share calculation all related measures in tax format

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak - Amit, as for LMSP, I have tweaked the total sales figure to reflect the last month, which means for Feb, it shows Jan.

The measures used in dax format as below :

LMSP Val = 
Var _Maxdate = MAX('Date Table'[Date])
Return
   IF(DAY(_Maxdate)<>DAY(DATE(YEAR(_Maxdate),MONTH(_Maxdate)-1,DAY(_Maxdate))),
   BLANK(),
   CALCULATE(
       TOTALMTD('Measures tray'[Total Sales], DATEADD('Date Table'[Date],-1,MONTH)
    )
    ))
MTD Val = 
    TOTALMTD('Measures tray'[Total Sales],'Date Table'[Date])

let me know, if this helps, or if you need something more to work thru' this.

Thanks for the quick revert

Helpful resources

Announcements
Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan NL Carousel

Fabric Community Update - January 2025

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