Forum Discussion
Date range determines appropriate values
Hi PBI_V,
I'd like to suggest you create a calendar table with full date range, then use calendar date and property name column to create matrix with measure as value field.(calendar not has relationship to original table)
Sample table:
Calendar = CALENDAR ( MIN ( VALUES ( Table[From] ) ), MAX ( VALUES ( Table[To] ) ) )
Measure:
RoomCount =
VAR _currentDate =
SELECTEDVALUE ( Calendar[Date] )
RETURN
CALCULATE (
SUM ( Table[Room Count] ),
FILTER ( ALL ( Table ), _currentDate IN CALENDAR ( Table[From], Table[To] ) ),
VALUES ( Table[Property Name] )
)
In addition, you can also try to expand date column to getdate date to create visualization.
Convert date ranges into list of dates?
Regards,
Xiaoxin Sheng
- PBI_V8 years agoFrequent Visitor
Hi Xiaoxin!
This is looking promising so far!
Can I ask a few questions regarding the solution to date:
- Is the Calendar table required if I have an existing Date Table in my model, spanning the From and To dates specified?
If not can you suggest how this might change the measure to utilise an existing date table? - The measure works great but only when utilising the dates from the Calendar table, even when a relationship is created between the Calendar and Date Table?
- Unfortunately the measure only works when specifiying the Room Count on a daily basis, it does not appear to facilitate summarisation at week, month, year level etc. can this be achieved?
Again, Anonymous thanks for the help so far, it is definitely progressing.
Kind regards
PBI_V
- Anonymous8 years agoNot applicable
Hi PBI_V,
#1. You can also use existed calendar table to replace steps and formula what I told about.
#2. Nope, calendar only used to get current date value to compare with two date column from fact table, relationship not the required.
#3. Unfortunately, 'in' operation not works to compare many to many records, it only support one to many.
It you want to compare with summarized records, I think create a expand table should be suitable for your requirement.
Spread revenue across period based on start and end date, slice and dase this using different dates
Regards,
Xiaoxin Sheng
- Is the Calendar table required if I have an existing Date Table in my model, spanning the From and To dates specified?