how to fill down values using Azure Data Factory

半世苍凉 提交于 2021-02-11 15:15:34

问题


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

  1. Create a new data flow
  2. Add a Source transformation that points to your text file
  3. Click on the script behind button on top right of browser UI
  4. Hit Enter to create newline at the bottom the script
  5. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!