问题
sorry for the basic question, I am coming from PowerQuery background, and started using ADF for a new Project. first I started wrangling data flows and fill down values is not supported, Now I am trying with mapping data flow and I can't find in the documentation how to fill down a value ?
see example I have the ID column and looking to add FILL_ID
回答1:
This data flow script snippet will do the trick:
source1 derive(dummy = 1) ~> DerivedColumn1 DerivedColumn1 window(over(dummy), asc(movie, true), startRowOffset: -1L, endRowOffset: 0L, Rating2 = first(coalesce(Rating))) ~> Window1 Window1 derive(Rating = iif(isNull(Rating),Rating2,Rating)) ~> DerivedColumn2
- Create a new data flow
- Add a Source transformation that points to your text file
- Click on the script behind button on top right of browser UI
- Hit Enter to create newline at the bottom the script
- Paste the above snippet and click OK
You should now see a Derived Column, Window, and another Derived. Go into the Window and 2nd Derived Column to change my column names to yours for sort and the coalesce function. THen in the 2nd Derived Column, pick the names of your columns.
The first derived creates a dummy var that you'll need because your use case is to pick the previous non-null value across the entire dataset.
The Window sorts the data because your use case requires it and the window column creates a new column that uses coalesce() to find first non-null.
The 2nd Derived Column swaps in the previous value is the current is NULL.
回答2:
You can use DerivedColumn.
1.add a column or select a column exist in your source.
2.enter an expression,if value of your column is null(you can check this by using Data preview),you can use iifNull function.About expression in dataflow,you can refer this.
来源:https://stackoverflow.com/questions/63324387/how-to-fill-down-values-using-azure-data-factory