Forum Discussion
Fill blanks with previous value
- 8 years ago
what do you mean by 'outside of Power Query'? is it calculated table?
in DAX you can try this, it works as long as Month column has type dateValue2 = VAR CurrentCar = 'Table'[Car] VAR CurrentDate = 'Table'[Month] VAR LastDateWithValue = CALCULATE ( MAX ( 'Table'[Month] ), FILTER ( 'Table', 'Table'[Value] <> BLANK () && 'Table'[Car] = CurrentCar && 'Table'[Month] <= CurrentDate ) ) RETURN CALCULATE ( SUM ( 'Table'[Value] ), FILTER ( 'Table', 'Table'[Car] = CurrentCar && 'Table'[Month] = LastDateWithValue ) )
Unfortunately the table is outside of power query, is there a solution in DAX?
what do you mean by 'outside of Power Query'? is it calculated table?
in DAX you can try this, it works as long as Month column has type date
Value2 =
VAR CurrentCar = 'Table'[Car]
VAR CurrentDate = 'Table'[Month]
VAR LastDateWithValue =
CALCULATE (
MAX ( 'Table'[Month] ),
FILTER (
'Table',
'Table'[Value] <> BLANK ()
&& 'Table'[Car] = CurrentCar
&& 'Table'[Month] <= CurrentDate
)
)
RETURN
CALCULATE (
SUM ( 'Table'[Value] ),
FILTER (
'Table',
'Table'[Car] = CurrentCar
&& 'Table'[Month] = LastDateWithValue
)
)- Anonymous6 years agoNot applicable
I used your query and to me, it fills the previous value to blank rows but add some garbage value to existing row value
- TaufikMaggangka4 years agoHelper II
Hi Stachu ,
I have same case, but the data type of column that need to fill is "Text? type. I try to using your dax but got an erro because SUM dax can used for data type of text.
basically I have column like this, I need to fill the "status" based on previous date with same school ID.
Any help will be really appreciate.School ID Date Status 1 1 nov 2021 High 2 1 nov 2021 Medium 3 1 nov 2021 Low 1 2 nov 2021 High 2 2 nov 2021 Low 3 2 nov 2021 - InsHunter3 years agoHelper II
Hi,
I have a similar situation for me with forward filling of text based on conditions. The logic with SUM works well for numeric. Your solution will greatly help me. Thanks in Advance.Regards.
- lucasneedhelp3 years agoHelper I
Hi Stachu
I tried your code, but it says a single value for column 'car' in table cannot be determined. could you please help