Prevent Blank Rows From Showing

SimonNU

Board Regular
Joined
Jul 11, 2013
Messages
140
The below variance formula calculates correctly except it lists all dimensions in a pivot table, even ones which calculate to nothing. So when pivoted against a large dimension column, the pivot table blows to 1000 lines for example, instead of the 5 which actually contain data.

How do I prevent this from happening?

Code:
Metric Variance:=IF(HASONEVALUE('Source'[Data]),
   SWITCH(VALUES('Source'[Data]),
     "Current Year Actuals", 1,
     "Last Year Actuals", DIVIDE(CALCULATE([Metric],'Source'[Data]="Current Year Actuals") - CALCULATE([Metric],'Source'[Data]="Last Year Actuals"),CALCULATE([Metric],'Source'[Data]="Last Year Actuals")),
     "Current Year Plan", DIVIDE(CALCULATE([Metric],'Source'[Data]="Current Year Actuals") - CALCULATE([Metric],'Source'[Data]="Current Year Plan"),CALCULATE([Metric],'Source'[Data]="Current Year Plan")),
     "Current Year Forecast", DIVIDE(CALCULATE([Metric],'Source'[Data]="Current Year Actuals") - CALCULATE([Metric],'Source'[Data]="Current Year Forecast"),CALCULATE([Metric],'Source'[Data]="Current Year Forecast")),
     BLANK()
    )
  )
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Please disregard. I simply needed to account for all results using BLANK()

Code:
Metric Variance:=IF(HASONEVALUE('Source'[Data]),   SWITCH(VALUES('Source'[Data]),
     "Current Year Actuals", BLANK(),
     "Last Year Actuals", DIVIDE(CALCULATE([Metric],'Source'[Data]="Current Year Actuals") - CALCULATE([Metric],'Source'[Data]="Last Year Actuals"),CALCULATE([Metric],'Source'[Data]="Last Year Actuals")),
     "Current Year Plan", DIVIDE(CALCULATE([Metric],'Source'[Data]="Current Year Actuals") - CALCULATE([Metric],'Source'[Data]="Current Year Plan"),CALCULATE([Metric],'Source'[Data]="Current Year Plan")),
     "Current Year Forecast", DIVIDE(CALCULATE([Metric],'Source'[Data]="Current Year Actuals") - CALCULATE([Metric],'Source'[Data]="Current Year Forecast"),CALCULATE([Metric],'Source'[Data]="Current Year Forecast")),
     BLANK()
    ),
BLANK()
  )
 
Upvote 0

Forum statistics

Threads
1,224,046
Messages
6,176,070
Members
452,704
Latest member
Michael AA

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top