Forum Discussion

db1Intermtn's avatar
db1Intermtn
Icon for Helper I rankHelper I
6 years ago

Wrong Total with DAX Measure

 I have a DAX Measure to calculate the total revenue for each week. I am not getting the correct total from the measure.

I checked the weekly values and they are correct but the total is not correct.

I also put the same measure in a card visual still the total is wrong.

 

 

Total =
VAR _thisyear =
    YEAR ( [Today] )
VAR _currentweek =
    WEEKNUM ( [Today] ) 
VAR _minweek =
    CALCULATE (
        SUMMARIZE (
            FactRevenue,
            "Min Date lY", CALCULATE ( MIN ( FactRevenue[weeknum] ) )
        ),
        FILTER ( DimCalendar, DimCalendar[CalendarYear] = _thisyear - 1 )
    )
VAR _total =
    SUMX (
        SUMMARIZE (
            FactRevenue,
            FactRevenue[CalendarWeekKey],
            "Revenue YTD", CALCULATE (
                SUM ( FactRevenue[Revenue] ),
                FILTER (
                    DimCalendar,
                    DimCalendar[CalendarWeekNumber] <= _currentweek
                ),
                FILTER ( DimCalendar, DimCalendar[CalendarYear] = _thisyear ),
                FILTER (
                    DimCalendar,
                    DimCalendar[CalendarWeekNumber] >= _minweek
                ),
                GROUPBY ( Branch, Branch[Branch] )
            )
        ),
        [Revenue YTD]
    )
RETURN
    IF ( ISBLANK ( _total ), BLANK (), _total )

 

 

 

5 Replies