jcoke
jcoke

Reputation: 1891

SUM over column without using SUMMARIZE function

I have created a DAX code using SAMEPERIODLASTYEAR which returns the correct value within a table but on a card visual and in the grand total it shows an incorrect value.

DAX:

ROS£PreviousYear = 
    IF (
    ISFILTERED('Calendar'[weekNumWeekCommence]) || ISFILTERED('Calendar'[Calendar Financial Year]),
    CALCULATE ( 
        [ROS £ 2],
        SAMEPERIODLASTYEAR('Calendar'[Calendar Date])
    ),
    0
)

Output:

enter image description here

Is there a way I can get the correct sum for that previous year column without using the SUMMARIZE function?

Upvotes: 1

Views: 154

Answers (1)

Sam Nseir
Sam Nseir

Reputation: 12111

Normally it would simply work for the Total but it seems other things are at play. As a test, try:

ROS£PreviousYear = 
  IF (
    ISFILTERED('Calendar'[weekNumWeekCommence]) || 
    ISFILTERED('Calendar'[Calendar Financial Year]),
    
    SUMX(
      VALUES('Campaign Overview'[day_id]),
      CALCULATE ( 
        [ROS £ 2],
        SAMEPERIODLASTYEAR('Calendar'[Calendar Date])
      )
    ),
    
    0
  )

Upvotes: 1

Related Questions