Michael Serres
10/24/2022, 9:30 AMIvan Nejezchleb
10/24/2022, 11:54 AMMichael Serres
10/24/2022, 12:12 PMMichael Serres
10/24/2022, 12:21 PMIvan Nejezchleb
10/24/2022, 1:15 PMMichael Serres
10/25/2022, 9:27 AMMichael Serres
10/25/2022, 10:53 AMIvan Nejezchleb
10/26/2022, 8:13 AMJiri Zajic
10/26/2022, 9:38 PM.forItems()
and .withDimensions()
that are closely related to seriesBy/slicesBy
and resultSpec
props respectively. Hopefully this will shed some light on the issue.Jiri Zajic
10/26/2022, 9:43 PMseriesBy
and slicesBy
is to build various tables in Analytical Designer (try moving items between ROWS and COLUMNS buckets) and investigating the executeAfm call payload — you'll observe that oftentimes the AFM defines the same attributes and measures, but it's the resultSpec's dimensions that make the desired pivot.Jiri Zajic
10/26/2022, 9:44 PMJiri Zajic
10/26/2022, 9:47 PMIvan Nejezchleb
10/27/2022, 8:29 AMseriesBy
and slicesBy
and their placement to the correct dimension in created executionMichael Serres
10/31/2022, 7:35 AMMichael Serres
10/31/2022, 8:09 AMMichael Serres
10/31/2022, 8:09 AMIvan Nejezchleb
10/31/2022, 8:13 AMconfig
param by execution instance created manually by you.
To do so, you need to call createExecution
similarly to
https://github.com/gooddata/gooddata-ui-sdk/blob/master/libs/sdk-ui/src/execution/useExecutionDataView.ts#L151
and then use its .withDimensions
method to get ResultSpec as you needIvan Nejezchleb
10/31/2022, 8:14 AMMichael Serres
10/31/2022, 10:39 AMMichael Serres
10/31/2022, 11:30 AMJiri Zajic
11/01/2022, 1:58 AMuseExecutionDataView()
hook, but the analogy should be the same.
I attached 3 screenshots. In the first picture the dimensions are defined automatically, so there's only one dimension by default.
In the second picture there's two dimensions (newTwoDimensional()
) defined programatically, stackBy
vs measures + viewBy
.
In the third picture there's two dimensions again, this time viewBy
vs measures + stackBy
.
Please observe how the data output changes in the console on the right. Even without knowing anything about the data, it should be clear that the dimensions of those computations are different.Michael Serres
11/01/2022, 8:09 AMMichael Serres
12/15/2022, 2:12 PMJiri Zajic
12/19/2022, 11:16 PMuseExecutionDataView()
you currently use is not "powerful" enough to accept a custom resultSpec
that defines custom slicing by dimensions.
However, if you look under the hood of our own useExecutionDataView()
that @Ivan Nejezchleb linked at https://github.com/gooddata/gooddata-ui-sdk/blob/master/libs/sdk-ui/src/execution/useExecutionDataView.ts#L151, you'll see that the useExecutionDataView()
internally uses the approach I described above that looks like this:
backend
.workspace(workspace)
.execution()
.forItems(seriesBy.concat(slicesBy), filters)
.withSorting(...sortBy)
.withDimensions(...dimensions);
It looks more complex but no need to worry! It's almost exactly the same, it's just the construct that's a bit different.Jiri Zajic
12/19/2022, 11:19 PMbackend
, and you should be able to import the hook like this: import { useBackend } from "../contexts/Auth";
and then get the backend instance like this: const backend = useBackend();
.
And then you need workspace
id, right? You should be able to import it like this: import { workspace } from "../constants";
.Jiri Zajic
12/19/2022, 11:32 PMJiri Zajic
12/19/2022, 11:32 PMimport React from "react";
import { ColumnChart } from "@gooddata/sdk-ui-charts";
import { useExecutionDataView } from "@gooddata/sdk-ui";
import { MeasureGroupIdentifier, newTwoDimensional } from "@gooddata/sdk-model";
import Page from "../components/Page";
import { useBackend } from "../contexts/Auth";
import { workspace } from "../constants";
import * as Md from "../md/full";
const Home = () => {
const backend = useBackend();
console.log(backend);
console.log(workspace);
const metric = Md.AveragePriceOfProducts;
const viewBy = Md.ProductBrand;
const stackBy = Md.ProductCategory;
const filters = [];
// useExecutionDataView is not enough to change the resulSpec/dimensions
// const { result, error, status } = useExecutionDataView(
// {
// execution: {
// seriesBy: [metric],
// slicesBy: [viewBy, stackBy],
// filters
// }
// }
// );
// console.log(result, error, status);
const execution = backend
.workspace(workspace)
.execution()
.forItems(
[metric, viewBy, stackBy],
filters // could be [] for no filters
)
.withDimensions(
...newTwoDimensional(
[stackBy],
[MeasureGroupIdentifier, viewBy]
)
);
const { result, error, status } = useExecutionDataView(
{ execution }
);
console.log(result, error, status);
return (
<Page>
<div style={{ height: 400 }}>
<ColumnChart
measures={[metric]}
viewBy={viewBy}
stackBy={stackBy}
filters={filters}
/>
</div>
</Page>
);
};
export default Home;
Jiri Zajic
01/11/2023, 12:11 AMMichael Serres
01/31/2023, 10:00 AMTarik
01/31/2023, 1:21 PMnewArithmeticMeasure
) in the executionJiri Zajic
01/31/2023, 5:06 PMTarik
02/01/2023, 8:46 AMJiri Zajic
02/02/2023, 2:34 AMMichael Serres
03/06/2023, 4:24 PMMichael Serres
03/06/2023, 4:42 PMIvan Nejezchleb
03/07/2023, 4:18 PMMichael Serres
03/08/2023, 5:14 AMIvan Nejezchleb
03/08/2023, 5:03 PMMichael Serres
03/09/2023, 5:22 AMMichael Serres
03/09/2023, 5:37 AMIvan Nejezchleb
03/09/2023, 9:59 AMIvan Nejezchleb
03/09/2023, 10:00 AMMichael Serres
03/09/2023, 10:43 AMIvan Nejezchleb
03/09/2023, 11:02 AM