Custom Date Range

Capt.Ragnar

Board Regular
Joined
Jun 6, 2012
Messages
138
I need the range of days in a table (where a single month has been selected ) to return the 14th of the prior month through month end of the selected month.

I am using the BasicCalendarUS table from the Azure Marketplace as my date table for reference if it aids in a solution.



Any help is appreciated.
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
How about posting a sample workbook. This is fairly straightforward but it will help to know your data model. Is the 14th a significant date each month? If so you should probably build a custom calendar table.
 
Upvote 0
How about posting a sample workbook. This is fairly straightforward but it will help to know your data model. Is the 14th a significant date each month? If so you should probably build a custom calendar table.

I'm open to either, but the logic on a table where dates are not unique relating back to source data would seem difficult.

I provided a sample wkbk here. http://1drv.ms/1UH5jPu

Thanks again.
 
Upvote 0
Here is a working solution https://dl.dropboxusercontent.com/u/30711565/45DayLookBack_TestWkBk2.xlsx

It uses a disconnected dates table that contains the start and end dates of each month. The user selects one of the months and then an if statement checks if each date in your data table is in that month or >=14th of the prior month. If it is, it displays the answer

Code:
=if(countrows(FILTER (        DailyBalance,
        DailyBalance[Date] >= 
        	DATE ( 
            	YEAR ( LASTDATE(Selector[Last Day] )), 
            	MONTH ( LASTDATE(Selector[Last Day])) - 1 ,
            	14 )
             && 
        DailyBalance[Date] <=  LASTDATE(Selector[Last Day] )
    ))>0,[Sum of Balance])
 
Upvote 0
Help on this line if you can:

,[Sum of Balance])

I used a table in the example but in the actual data that field is a Calculated Field in another table. Is it possible to reference the calculated field in the formula you have above or just create a queried table that replicates what I used in the sample workbook?
 
Upvote 0
[Sum of Balance] is an implicit calculated formula (I will call it a measure). This is not good practice but fine for demo workbooks like this. You should write your own measure that does the calculation you need. It may or may not work if it is in another table - it depends on the shape of your data model. Filter propagation is a deep topic and you really need to understand it if you want to be a DAX ninja. I cover this extensively in my book in Chapters 5, 8 and 9 (Learn to Write DAX - the book for all Excel users)

If you can post a picture of your full data model (showing table names) and which table has your measure, I can help you understand if it will work. Or you can just test it.
 
Upvote 0

Forum statistics

Threads
1,223,162
Messages
6,170,431
Members
452,326
Latest member
johnshaji

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