Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Inserting records from source with DAX

I am trying to figure out how to insert records from a new source from DAX. I imagen it would look something close to this. Assuing the table name is users and the column is Manager. I would be greatful for any help.

 

Table.InsertRows(#"Renamed Columns", 0,{Table.SelectRows(Table.SelectColumns(Source{[Name="users"]}[Data],{"Manager"}),"Manager")}

4 Replies

  • I don't quite understand how DAX is involved. Are you trying to load data from a DAX calculated table/column into a query in the same pbix file? If so, you're out of luck. DAX calculated tables/columns are evaluated after all the queries load and cannot be referenced in the query editor.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Lets say I am trying geting data from a new source 3 names.

    Larry

    Mary

    Mark

    I need to add some calcuated dates for each name per quarter. Like this

     

    Larry   1/1/2022

    Larry   4/1/2022

    Larry   7/1/2022

    Larry   10/1/2022

    Mary   1/1/2022

    Mary   4/1/2022

    Mary   7/1/2022

    Mary   10/1/2022

    Mark   1/1/2022

    Mark   4/1/2022

    Mark   7/1/2022

    Mark   10/1/2022

     

    I know I can apply the dates with something like this Date.AddQuarters(Date.StartOfYear(Date.From(DateTime.FixedLocalNow())),0)

    but I dont know how to loop and itirate each name so it comes out that way when I am inserting the rows.

     

    Let me know if this make sense.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Anonymous ,

       

      Agree with AlexisOlson .

      And in Power BI Desktop, you can use the CROSSJOIN()  function to returns a table that contains the Cartesian product of all rows from all tables in the arguments. The CROSSJOIN() function is DAX language.

       

      Best Regards,

      Stephen Tao

       

      If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.