Forum Discussion
Nemesis_3
Nov 05, 2021Copper Contributor
How to use the result of one query in another query?
I'm trying to call an API, where I need (for starters) 2 queries (M code). For this, the 2nd query calls an outcome from the 1st query. However, I get the error message in doing so: "[Expression...
- Nov 05, 2021
Nemesis_3 If your final step of the Token query looks similar to this:
Then all it takes is a right-click and choosing "Drill down":
Which will end up looking like this:
JKPieterse
Nov 05, 2021Silver Contributor
Make sure the token query returns a single value, not a table by clicking on the value of the token in the last step of that query
- Nemesis_3Nov 05, 2021Copper ContributorHi, when applying the M code in the query editor, the applied steps are as follows:
https://ibb.co/hgQG9X5
For each step the following formula is generated:
= Web.Contents(Link_getToken,
= Json.Document(GetJson)
= Record.ToTable(FormatAsJson)
= #"Converted to Table"{0}[Value]
= #table(1, {{access_token_result}})
Which results in the overaal result:
https://ibb.co/qJTz8bM
This means a table is created? If so, this can be undone by removing the last formula (= #table(1, {{access_token_result}}))?- JKPieterseNov 05, 2021Silver Contributor
Nemesis_3 If your final step of the Token query looks similar to this:
Then all it takes is a right-click and choosing "Drill down":
Which will end up looking like this:
- Nemesis_3Nov 05, 2021Copper ContributorHa, that one works pretty well! Now the following problem pops up, regarding credentials in the second query (https://ibb.co/SXRNHcn)... Most likely not related to the problem as posted I think, or do you see any relation (and / or, solution)? The weird thing is, the same M code in Power BI works like a charm...