Forum Discussion
Use previous data to fill in blanks in table
Hi REKLP
I had a look at your file. I think the problem probably lies with using the fact tables to filter rather than the dimension table. That is dangerous and can easily bring about unpleasant side effects. I think we've been trying unnecessarily intricate approaches while what you require can be done in a simpler manner.
Instead of the measure that you have:
m_ActiveEmployees =
CALCULATE (
SUM ( ActiveEmployee[Active] );
FILTER (
ALLEXCEPT ( ActiveEmployee; region[ED_REGION] );
ActiveEmployee[Year-Month] <= MAX ( ActiveEmployee[Year-Month] )
)
)
try this one and, I believe, the issue will be no more. Same approach for terminated employees.
m_ActiveEmployees_V2 = CALCULATE (
SUM( ActiveEmployee[Active] );
FILTER (
ALL(MonthTable[Year-Month]);
MonthTable[Year-Month] <= MAX ( MonthTable[Year-Month] )
)
)Now there are two things to take into account with this approach:
1. Do you want to do the cumulative count per year only? If so, you'll to need to add the current year to the filter because as the V2 is now, it accumulates guess since the beginning of time in your 'MonthTable table (1955)
2. If it's actually per year you'll have to decide what to do if the first month is blank. Right now it will be left blank. What would the previous value have to be in that case?
Let me know if this does the trick. Here is the file with the new measures.
Hi AlB,
I need it to be a cumulative sum throughout the whole table. So January of 2018 should start with what 2017 ended off with, and so on.
Here's an updated PBIX that will include 2017 data (sorry I didn't do this before).
https://www.dropbox.com/s/ab8lh8wcwulxrx8/Demo.pbix?dl=0
In the PBIX, I have two measures. The m_ActiveEmployees gives the correct sum, it's just not showing for every month like it should. And the m_ActiveEmployees_V2, it shows for every month, but it's not the correct sum.