Quantcast
Channel: SQL Server Analysis Services Forum
Viewing all articles
Browse latest Browse all 2472

DAX for previous available day (PREVIOUSDAY with holidays / weekends)

$
0
0

Hello all,

I ran into the following problem recently, but so far I haven't been able to come up with a simple measure to solve it. I still think it should be easy, so I'm probably missing something.

My tables are
InventoryState with columns Date, Product ID, Closing Balance
Products with columns Product ID, Name
Calendar with columns Date, Week, Month, Year

My business requirement is to have a measure to report the Opening Balance given any date filtering (e.g. months as rows, weeks as rows, etc). The Opening Balance is just the Closing Balance of the previous date.

I thought the PREVIOUSDAY() function would do the trick, but the problem is that my inventory isn't calculated on weekends and holidays. My calendar is populated accordilingly, i.e., there are only entries for working days. I thought PREVIOUSDAY() would handle that, but apparently it doesn't (it returns blanks on mondays and dates that are preceeded by holidays).

Is there any way to come arround that limitation? I thought about using formulas like CALCULATE(MAX(Calendar[date]);Calendar[date]<MIN(Calendar[date])) to try to determine the previous available day, but it won't accept the MIN inside the filter.

Can anybody provide me with pointers?

Best regards,

Carlos Jourdan


Viewing all articles
Browse latest Browse all 2472

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>