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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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

@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

@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
July 2024 Power BI Update

Power BI Monthly Update - July 2024

Check out the July 2024 Power BI update to learn about new features.

Top Solution Authors