Formula error variant data-type

masplin

Active Member
Joined
May 10, 2010
Messages
413
I am looking up a date value on a larger table so sometimes there will be a blank value and sometimes a date. I assume this is the reason I get the error about variant date types. Couple of questions:

1. I'm copying the formula from PowerPivot 2010 to PP 2016. Is this an "enhancement" in 2016 that didn't used to error in older versions? PP 2010 finds the date with no issue
2. I have been able to work round this by using an IF statement that checks if the lookup produces a blank, if so blank , otherwise the value. This works , but has made the calculation enormous as below. Is there a neater way to achieve the same thing as the original lookup as quite long? I tried IFERROR, but that doesn't work

Code:
=IF(   CALCULATE(
                           VALUES('Posted Document Header'[Posting Date]),
                          FILTER('Posted Document Header',
                                         'Posted Document Header'[VRM]=MOTLeads[VRM]  &&
                                         'Posted Document Header'[Posting Date]>[MOT Due Date]-35 &&
                                          'Posted Document Header'[Posting Date]<[MOT Due Date]+60 &&
                                         'Posted Document Header'[Inc MOT]>0 &&
                                          'Posted Document Header'[Rank Vehicle Visit]=CALCULATE(
                                                                                                                                    MIN('Posted Document Header'[Rank Vehicle Visit]),
                                                                                                                                    FILTER('Posted Document Header',
                                                                                                                                                   'Posted Document Header'[VRM]=MOTLeads[VRM]  &&
                                                                                                                                                   'Posted Document Header'[Posting Date]>[MOT Due Date]-35 &&
                                                                                                                                                   'Posted Document Header'[Posting Date]<[MOT Due Date]+60 &&
                                                                                                                                                    'Posted Document Header'[Inc MOT]>0
                                                                                                                                                    )
                                                                                                                                     )                                                                                )
                              )=BLANK(),
                              BLANK(),
                               CALCULATE(
                           VALUES('Posted Document Header'[Posting Date]),
                          FILTER('Posted Document Header',
                                         'Posted Document Header'[VRM]=MOTLeads[VRM]  &&
                                         'Posted Document Header'[Posting Date]>[MOT Due Date]-35 &&
                                          'Posted Document Header'[Posting Date]<[MOT Due Date]+60 &&
                                         'Posted Document Header'[Inc MOT]>0 &&
                                          'Posted Document Header'[Rank Vehicle Visit]=CALCULATE(
                                                                                                                                    MIN('Posted Document Header'[Rank Vehicle Visit]),
                                                                                                                                    FILTER('Posted Document Header',
                                                                                                                                                   'Posted Document Header'[VRM]=MOTLeads[VRM]  &&
                                                                                                                                                   'Posted Document Header'[Posting Date]>[MOT Due Date]-35 &&
                                                                                                                                                   'Posted Document Header'[Posting Date]<[MOT Due Date]+60 &&
                                                                                                                                                    'Posted Document Header'[Inc MOT]>0
                                                                                                                                                    )
                                                                                                                                     )                                                                                )
                              )
                         )

Thanks Mike
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

Forum statistics

Threads
1,217,396
Messages
6,136,375
Members
450,006
Latest member
DaveLlew

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