Forum Discussion
Fill Future Dates in Date Dimension Table and then filter using 3rd Dimension Table
- Anonymous5 years ago
Hi Anonymous
I have a test in your sample. Please try this code.
M_Capacity = VAR _LASTDATE = CALCULATE(MAX(FACT_BackupStorage_Data[Date]),ALL(FACT_BackupStorage_Data)) VAR _LASTCAPACITY = CALCULATE(SUM(FACT_BackupStorage_Data[Capacity]),FILTER(ALL(FACT_BackupStorage_Data),FACT_BackupStorage_Data[Date] = _LASTDATE)) VAR _FirstEOLDate = MIN(DIM_BackupStorage_Nodes[EOL Date]) VAR _FirstEOLHOST = CALCULATE(MAX(DIM_BackupStorage_Nodes[Host]),FILTER(ALL(DIM_BackupStorage_Nodes),DIM_BackupStorage_Nodes[EOL Date] = _FirstEOLDate)) VAR _CAPACITYAFTEREOL = CALCULATE(SUM(FACT_BackupStorage_Data[Capacity]),FILTER(ALL(FACT_BackupStorage_Data),AND(FACT_BackupStorage_Data[Date] = _LASTDATE,FACT_BackupStorage_Data[Host]<>_FirstEOLHOST))) VAR _IF = IF(MAX(DIM_Date[Date])<=_LASTDATE,SUM(FACT_BackupStorage_Data[Capacity]),IF(MAX(DIM_Date[Date])<_FirstEOLDate,_LASTCAPACITY,_CAPACITYAFTEREOL)) VAR _RESULT = IF(_IF = BLANK(),BLANK(),_IF&""&"GB") RETURN _RESULTResult is as below.
Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous , You should not join two dimensions. so Date should not join with DIM_BackupStorage_Nodes .
You can use the date range from slicer as filter in the measures you need to filter date from DIM_BackupStorage_Nodes
measures =
=
var _max = maxx(allselected('Date'), 'Date'[Date])
var _min = maxx(allselected('Date'), 'Date'[Date])
return
calculate (countrows(FACT_BackupStorage_Data ), filter( DIM_BackupStorage_Nodes , DIM_BackupStorage_Nodes [EOL] >=_min && DIM_BackupStorage_Nodes [EOL] <= _max))
If needed, use all(Date) remove the filter from fact(that should be active), or use crossfilter for that.
You can keep both joins inactive and try userelationship as per need
- Anonymous5 years agoNot applicable
Hi amitchandak
Thanks so much for taking the time to reply.
I've attempted using the measure you applied above, but unfortunately was not successful. The measure shows only blanks when I create a table with the Date from the DIM_Date table and your measure.
I think I understand the concept of your measure, it's taking all selected dates from date dimension, giving me the value in the first stage of the calculate step, and then filtering it by dates when they are greater than the earliest EOL date.
I'm confused as to why it's not showing any values, as to me that logic makes sense. I've attached a screenshot below, and a scrubbed PBIX file, if you could point me to where I've gone wrong, it would be much appreciated! I have used CrossFilter / UseRelationship before, but not sure where I would apply them here.
- Anonymous5 years agoNot applicable
Hi Anonymous
I have a test in your sample. Please try this code.
M_Capacity = VAR _LASTDATE = CALCULATE(MAX(FACT_BackupStorage_Data[Date]),ALL(FACT_BackupStorage_Data)) VAR _LASTCAPACITY = CALCULATE(SUM(FACT_BackupStorage_Data[Capacity]),FILTER(ALL(FACT_BackupStorage_Data),FACT_BackupStorage_Data[Date] = _LASTDATE)) VAR _FirstEOLDate = MIN(DIM_BackupStorage_Nodes[EOL Date]) VAR _FirstEOLHOST = CALCULATE(MAX(DIM_BackupStorage_Nodes[Host]),FILTER(ALL(DIM_BackupStorage_Nodes),DIM_BackupStorage_Nodes[EOL Date] = _FirstEOLDate)) VAR _CAPACITYAFTEREOL = CALCULATE(SUM(FACT_BackupStorage_Data[Capacity]),FILTER(ALL(FACT_BackupStorage_Data),AND(FACT_BackupStorage_Data[Date] = _LASTDATE,FACT_BackupStorage_Data[Host]<>_FirstEOLHOST))) VAR _IF = IF(MAX(DIM_Date[Date])<=_LASTDATE,SUM(FACT_BackupStorage_Data[Capacity]),IF(MAX(DIM_Date[Date])<_FirstEOLDate,_LASTCAPACITY,_CAPACITYAFTEREOL)) VAR _RESULT = IF(_IF = BLANK(),BLANK(),_IF&""&"GB") RETURN _RESULTResult is as below.
Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Anonymous5 years agoNot applicable
Hi Anonymous
Thank you so much! That's working perfectly after having applied it to my real dataset also.
Really appreciate the help!
Kind regards
Andy