Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Create Dynamic parameter to load data in Power BI

Hi,   I am very new to Power BI. I have one requirement to load the data for one field from previous year to next 3 years. So, the filed is 'PO_Plan_Receipt_Year' and it has all years starting fro...
  • v-juanli-msft's avatar
    v-juanli-msft
    7 years ago

    Hi Anonymous

    Please pay attention to the bold character, paste the following code in your Advanced editor.

    let
    Source = Sql.Database("10.76.62.207", "sagedb"),
    dbo_V_OPPORTUNITIES_OIF = Source{[Schema="dbo",Item="V_OPPORTUNITIES_OIF"]}[Data],
    #"Replaced Value" = Table.ReplaceValue(dbo_V_OPPORTUNITIES_OIF,"","0.0",Replacer.ReplaceValue,{"OIF_Value_EUR"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Replaced Value",{{"OIF_Value_EUR", type number}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Opp_Key", each [Opportunity_ID]&"-"&Date.ToText([Load_Creation_Date])),
    #"Changed Type1" = Table.TransformColumnTypes(#"Added Custom",{{"PO_Plan_Receipt _Year", Int64.Type}}),
    Startdate=Date.Year(DateTime.LocalNow())-1,
    Enddate=Date.Year(DateTime.LocalNow())+3,
    #"Filtered Rows" = Table.SelectRows(#"Changed Type1", each [PO_Plan_Receipt _Year] >= Startdate and [PO_Plan_Receipt _Year] <= Enddate)
    in
    #"Filtered Rows

     

    Best Regards

    Maggie