Error using CUBESET with date range

Bagharmin

Board Regular
Joined
Nov 22, 2010
Messages
168
I've been using this CUBESET function without issue for a couple of weeks to calculate a sum between two dates, but today it's giving me an #N/A error:

=CUBEVALUE("ThisWorkbookDataModel","[Measures].[Hours]]","[AllWork].[Group].[GrpOne]","[History].[CurrentlyActive].[Active]",CUBESET("ThisWorkbookDataModel","[AllWork].[Date].&["&TEXT(PrevWk_Start,"YYYY-MM-DDThh:mm:ss")&"]:[AllWork].[Date].&["&TEXT(PrevWk_End,"YYYY-MM-DDThh:mm:ss")&"]"))

It looks like it's due to no data existing with the date given by PrevWk_End (April 3, 2021). As a temporary fix I just changed PrevWk_End to 'PrevWk_End - 1' since data does exist with that date (April 2, 2021), but I can't leave it like that going forward. What's the best way to fix this so that I don't run into this in the future? I'm assuming the same fix will need to be applied to 'PrevWk_Start' in case I run into a situation where I have no data with that date either.
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

Forum statistics

Threads
1,214,651
Messages
6,120,739
Members
448,989
Latest member
mariah3

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