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.
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.
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
_RESULT
Result is as below.
Best Regards,
Rico Zhou
If 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