Forum Discussion

santoshlearner2's avatar
santoshlearner2
Icon for Resolver II rankResolver II
7 months ago
Solved

Total is wrong when categorised is vendor wise

Dear All, Measure used:  Dax measures for total sales is  CALCULATE(sum(table1(sales), DATESMTD(DIMDatesQ[EOM])). I tried using sumx but gives and error.   Issue: When I use only the month and t...
  • pcoley's avatar
    pcoley
    7 months ago

    santoshlearner2 Please check which MonthDate-field are you using in the report. 
    One common mistake is to have a DateDimTable, but use the Date-field from a transaction table.
    Best practice: Use the DateDimTable Field at the report 

    Alternate solution if you are using the Table1[Month] field at the report: 

    Sales Amount MTD :=
    VAR LastVisibleDate =
        MAX ( 'Table1'[Month] )
    VAR CurrentYear =
        YEAR ( LastVisibleDate )
    VAR CurrentMonth =
        MONTH ( LastVisibleDate )
    VAR SetOfDatesMTD =
        FILTER (
            ALL ( 'Table1'[Month] ),
            'Table1'[Month] <= LastVisibleDate
                && YEAR ( 'Table1'[Month] ) = CurrentYear
                && MONTH ( 'Table1'[Month] ) = CurrentMonth
        )
    VAR Result =
        CALCULATE (
            SUM ( Table1[Sales] ),
            SetOfDatesYTD,
            KEEPFILTERS ( 'table 1'[Vendor code] )
        )
    RETURN
        Result




    If this response was helpful in any way,
    I’d gladly accept a kudo.

    Please mark it as the correct solution.
    It helps other community members find their way faster.

  • santoshlearner2's avatar
    santoshlearner2
    7 months ago

    Hi,

    Thanks for everyone for assisting. I truly appreciate, But the response is not working. I cannot upload any file due to restrictions. Closing this, Thanks for every one.