Forum Discussion

TomMartens's avatar
TomMartens
Super User
9 years ago

Please use Table.FromRows(...) to create sample data

Hey,

 

I have to admit something.

 

Sometimes I read questions, that I will not or can not answer, or not even try to answer, and just for a simple reason.

 

I do not have the time to create sample data that is shown in a screenshot, or  is just vaguely described (with a great risk that I do not fully understand the problem).

 

This lack of an easy to reproduce example immediately prevents the chance to learn something new by trying to answer the question. 

 

In my opinion, there is no way that easy as to use the Power Query function

Table.FromRows(...)

This function is described here:

https://msdn.microsoft.com/en-us/library/mt260791.aspx

 

The following line of code

=Table.FromRows({{1, "Bob", "123-4567"} , {2, "Jim", "987-6543"}}, {"CustomerID ", "Name", "Phone"})

creates a table. With two records and the Columns "CustomerID", "Name", "Phone"

 

You can use this function by

1. Goto "Edit Queries" from the main window in Power BI

2. Create a "New Query" using the context menu in the queries pane and choose "Blank Query"

 

I my opinion using this method provides the following advantages

  • you don't have to share data, you don't want to
  • reducing the problem to the minimum level of complexity provides implicit insight in the essence of the problem
  • gives me a chance to learn something new by trying to answer the question
  • it is just polite

May the power bi with you

1 Reply