POWER QUERY [Expression.Error] Cannot convert the value null to type Table - apply

SOLVED USING A DIFFERENT APPROACH (see at the end)
I am trying to combine some queries into one by using the Table.Combine() function.
If I explicitly write the name of each query (e. g., Table.Combine({#"Name of query 1", #"Name of query 2"})) and then apply the changes, everything works fine.
However, since I want to make it dynamic, instead of writing a list of names, I pass the function a list of tables generated in a previous step:
So after I get this table, the next step is: = Table.Combine(PreviousStep[Value]). Note that Value is the name of the column that contains the tables. Apparently, by doing so this column of a table containing tables is converted to a list containing tables. This works fine (I can preview the resultset) until I hit that Apply changes button. When I do it, this message pops up:
I had a look at these threads: https://community.powerbi.com/t5/Desktop/We-cannot-convert-the-value-null-to-type-Table/td-p/391064, https://community.powerbi.com/t5/Desktop/We-cannot-convert-the-value-null-to-type-table/m-p/346056, but it didn't work. I've tried other approaches as well.
Further information:
Power BI Desktop version: 2.106.582.0 64-bit (June 2022)
Data source: combining existing queries that come from a single Excel file.
Steps followed to get that list of tables that I pass the Table.Combine() function:
let
Origen = #sections[Section1],
#"Convertido en tabla" = Record.ToTable(Origen),
#"Errores quitados" = Table.RemoveRowsWithErrors(#"Convertido en tabla", {"Value"}),
Personalizado1 = Table.SelectRows(#"Errores quitados", each Text.StartsWith([Name], "COMPRAS Y GASTOS")),
Personalizado2 = Table.Combine(Personalizado1[Value])
in
Personalizado2
I access all the queries I have (with the #sections keyword), convert it to a table, remove possible errors, filter to get the queries I want (the ones starting by "COMPRAS Y GASTOS") and then try to combine the queries).
A DIFFERENT APPROACH
What I wanted to do was merge tables that came from an Excel file, each of them referring to a year (2019, 2020, 2021, 2022). But I also wanted the combined table to update when new sheets were added on Excel (2023, 2024...).
I've tried many different approaches, like generating a dynamic list (from 2019 until the current year)... but for some reason none of them worked, even though the code apparently is correct.
So my new approach has been to create a sufficient amount of Excel sheets for the coming years (that are now empty, but when the new year comes the information will be filled in there), to create the queries referring to those sheets (they return empty tables) and merging those existing (but empty) tables with the ones from 2019-2022. This way, when data from 2023 is filled in in the sheet, the query is updated and it works.
It's a shame I couldn't actually solve the original problem I had, but this approach works.

Related

Power Bi web.contents Variables

Please excuse my lack of knowledge in explaining my problem as i have only just started learning Power Bi.
I am attempting to return data by using a dynamic variable within my source url.
Source = Json.Document(Web.Contents("https://api.****.com/jobs/{ID}/invoices", [Headers=[Authorization="Bearer "&GetToken()]]))
I have successfully returned the data i needed from multiple queries Blank Query 1 Query Names
However, i am trying to run a final query in which a job ID needs to be specified.
Source = Json.Document(Web.Contents("https://api.****.com/jobs/{ID}/invoices", [Headers=[Authorization="Bearer "&GetToken()]]))
With the bold item being the variable.
I have successfully returned values by hard coding the variable (seen below).
Hard coded variable
However, i would like to make dynamic in that it will return the values for all the Job ID's witin the "jobs" table.
Job Id's
I don't know if what im asking is possible, or if my explanation is good enough, but any help would be greatly appreciated!
What you are looking for is a custom function.
Make a function out of your above query by adding (ID) => in the first line and separating "ID" in your URL string.
(ID) =>
let
Source = Json.Document(Web.Contents("https://api.****.com/jobs/{" & ID & "}/invoices", [Headers=[Authorization="Bearer "&GetToken()]]))
in
Source
Of cause you can add all your other transformation steps too.
Now take your JobIDs table and add a column by invoking a custom function, select the above function and take the ID parameter from your ID column.
For every row you'll get a separate table and all that's left is simply expanding these tables into your query.
This will solve your problem.

Issues with PowerBI connector in PowerApps

Up front: this isn't about PowerBI tiles or bringing visualizations into PowerApps. There is a PowerBI data connector that provides a method called ExecuteDatasetQuery that allows for passing in a DAX query for, ostensibly, returning the data from a published dataset. It takes three parameters: workspaceGuid, datasetGuid, and queryText (with an optional object for serializer settings).
There is no query I can send this thing that doesn't return a giant empty table and I have no idea what I'm doing wrong. My queries, which work fine in other systems that do the same thing (JavaScript API calls, PowerAutomate, PowerBI Desktop), all produce a table with no columns and no values in those columns but with a number of rows equal to the rows I'd expect to get back from a query. The result, viewed in PowerApps, looks like this:
And, just for fun, I've converted the return to a JSON string and can confirm that the return is...
just empty. I can find no documentation of merit for the PowerBI connector or this method, so no luck there. Just wondered if anyone's had any experience with this thing and can maybe point me in the right direction. For reference, the query I'm trying to pass in (that works everywhere else) is:
DEFINE
VAR _reqs = SELECTCOLUMNS(MyTable,
"ReqNum",[Title],
"BusinessArea",[BusinessArea],
"Serial1",[Serial1],
"Serial2",[Serial2],
"Department",[Department],
"OM",[OM],
"Requestor",[Requestor],
"StrategicObjective",[ITStrategicObjective],
"Area",[Area],
"ProductLine",[ProductLine],
"ProjectManager",[ProjectManager],
"BusinessLiaison",[BusinessLiaison],
"Customer",[Customer],
"SolutionArchitect",[SolutionArchitect],
"VicePresident",[VicePresident],
"Created",DATEVALUE([Created])
)
EVALUATE
_reqs
ORDER BY
[Created] DESC
But the PowerApps method returns the same empty table even with something as simple as EVALUATE(MyTable).

SQL column renamed generating error in Power BI

Context:
I have a dates table that I pulled in just by checking its box in the add data wizard which generated this
= Source{[Schema="dbo",Item="vw_ReportDates"]}[Data]
then I renamed the column ReportDayNo to DayOfReportMonth and I now get to see DayOfReportMonth in the data model but I get an error saying ReportDayNo doesn't exist. I'm not sure what to do here, the code doesn't explicitly call out for ReportDayNo so I'm not sure where to correct this.
Question:
how do I tell Power Query this column no longer exists?
You have following options (for Table.RenameColumns step):
Delete this step completely (if ReportDayNo was only column you renamed);
Delete the chunk {"ReportDayNo", "DayOfReportMonth"} from your step (if there are other columns you renamed);
Add 3rd argument MissingField.Ignore to your Table.RenameColumns function. More info:
https://learn.microsoft.com/en-US/powerquery-m/table-renamecolumns

Google Sheets Array formula for counting the number of values in each column

I'm trying to create an array formula to auto-populate the total count of values for each column as columns are added.
I've tried doing this using a combination of count and indirect, as well as tried my hand at query, but I can't seem to get it to show unique value counts for each column.
This is my first time attempting to use query, and at first it seemed possible from reading through the documentation on the query language, but I haven't been able to figure it out.
Here's the shared document: https://docs.google.com/spreadsheets/d/15VwsL7uTsORLqBDrnT3VdwAWlXLh-JgoJVbz7wkoMAo/edit?usp=sharing
I know I can do this by writing a custom function in apps script, but I'd like to use the built-in functions if I can for performance reasons (there is going to be a lot of data), and I want quick refresh rates.
try:
=ARRAYFORMULA(IF(B5:5="",,TRANSPOSE(MMULT(TRANSPOSE(N(B6:99<>"")), SIGN(ROW(B6:99))))))
In B3 try
=ArrayFormula(IF(LEN(B5:5), COUNTIF(IF(B6:21<>"", COLUMN(B6:21)), COLUMN(B6:21)),))

How to Query Large Sharepoint 2013 Lists in Infopath 2010?

I'm designing an Infopath form to help guide people in a data creation process. The form needs to draw from a Sharepoint list that contains around 19,000 rows, each with six columns that contain attributes (Column 1 = Attribute A, Column 2 = Attribute B, etc.) I've reduced the first three columns to their own lists, which contain only a few hundred unique entries each, if that. When I get to Column 4, there are 8,000 unique entries, which makes querying the list outright impossible
In an attempt to get around the item limitation, I've created an Infopath form with a data connection to the list (which does not automatically query when the form is loaded). Additionally, I've added drop downs that sets values for the queryFields of the secondary data source (one for Column 1, another for Column 2, and another for Column 3). On the last drop down, I set an action to query the database, but I still get the error regarding limitations and that rules cannot be applied.
Is there any way to "pre-filter" the data connection so that I can bypass the limitation by only drawing the data I need? Am I going about this the right way?
Any guidance would be greatly appreciated.
Are you able to add indexes to your list columns that you intend to query on? I've found that I can get around the error message on list limits if I go to the list and add an index for the columns that I will be setting as query fields prior to running my query data connection.