Forum Discussion

Mbechet's avatar
Mbechet
Frequent Visitor
9 years ago
Solved

Variable parameter based on periods

Hi everyone, I have a set of 12 exact same excel files (one for each 12 previous months). I want to append them in one single historical source in Power BI. As I have a big set of data I cannot app...
  • v-caliao-msft's avatar
    9 years ago

    Mbechet,

     

    I have test it on my local environment, everything works fine.

    You can create a text parameter like 201706, 201707, 201708.... and then use it in you query like below.
    let
        Source = Excel.Workbook(File.Contents("C:\Users\v-caliao\Desktop\SampleDataSource\" & #"Parameter" & ".xlsx"), null, true),
        Sheet1_Sheet = Source{[Item="Sheet1",Kind="Sheet"]}[Data],
        #"Promoted Headers" = Table.PromoteHeaders(Sheet1_Sheet, [PromoteAllScalars=true]),
        #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Type", type text}, {"Sales", Int64.Type}})
    in
        #"Changed Type"

     

    Reference
    http://www.fourmoo.com/2016/11/23/power-bi-using-parameters-for-flat-file-csv-excel-sources/

     

    Regards,

    Charlie Liao