PierreBenko
New Member
- Joined
- Jul 12, 2012
- Messages
- 9
Hi all,
I have an Excel file with an underlying pretty complicated PowerQuery query.
On the Excel sheet, I have a table from a query, which displays only the needed information, without any redundancy (meaning, that you cannot calculate one column from another).
I want to have a button, which sets the values of a newly added column (which doesn't come from the query) according to values from another query.
Point is, that I don't want to have the whole query table on any sheet.
How can I do this in VBA? Is there a way to directly access the queries? Cube formulas?
For clarification:
Queries:
Base_Query (with all data):
Columns: Year, Country, Market Size, Revenue, Market Share
Table_Query (derived from Base_Query, only the columns to be displayed)
Columns: Year, Country, Market Share in 2021
Table on the Worksheet:
Columns: [Year, Country, Market Share in 2021], Market Share in current year
Button: Set defaults
What it should do:
1) get the [Revenue] from 2021 from Base_Query (for given Country)
2) get the [Market size] from 2021 from Base_Query (for given Country)
3) divide Revenue from 2021 with Market size from 2021
4) write the result to the [Market share in current year] column for given Country
So again, the question is, how can I get the values from Base_Query to a variable in VBA. (Step 2: how can I get several values according to filter criteria e.g. year and country)
Thank you in advance.
Peter
I have an Excel file with an underlying pretty complicated PowerQuery query.
On the Excel sheet, I have a table from a query, which displays only the needed information, without any redundancy (meaning, that you cannot calculate one column from another).
I want to have a button, which sets the values of a newly added column (which doesn't come from the query) according to values from another query.
Point is, that I don't want to have the whole query table on any sheet.
How can I do this in VBA? Is there a way to directly access the queries? Cube formulas?
For clarification:
Queries:
Base_Query (with all data):
Columns: Year, Country, Market Size, Revenue, Market Share
Table_Query (derived from Base_Query, only the columns to be displayed)
Columns: Year, Country, Market Share in 2021
Table on the Worksheet:
Columns: [Year, Country, Market Share in 2021], Market Share in current year
Button: Set defaults
What it should do:
1) get the [Revenue] from 2021 from Base_Query (for given Country)
2) get the [Market size] from 2021 from Base_Query (for given Country)
3) divide Revenue from 2021 with Market size from 2021
4) write the result to the [Market share in current year] column for given Country
So again, the question is, how can I get the values from Base_Query to a variable in VBA. (Step 2: how can I get several values according to filter criteria e.g. year and country)
Thank you in advance.
Peter