Skip to Content
0

VizFrame data aggregation

Apr 05 at 09:05 AM

24

avatar image

Hi to all,

I'm trying to create a graph using CDS and VizFrame. My problem is that the graph shows only the first value for each kind of value and doesn't aggregate and sum all the same data together.

This is the data structure that I receive from the backend:

{
  "results": [
    {
      "canale": "CANALE1",
      "tipo_operazione": "ATTIVAZIONE",
      "causale": "ATTIVAZIONE",
      "Data": "2017-03-08T00:00:00.000Z",
      "Totale_richieste_per_mese": 2,
      "Totale_richieste_ok_per_mese": 1,
      "Totale_richieste_ko_per_mese": 1
    },
    {
      "canale": "CANALE1",
      "tipo_operazione": "ATTIVAZIONE",
      "causale": "ATTIVAZIONE",
      "Data": "2017-03-09T00:00:00.000Z",
      "Totale_richieste_per_mese": 6,
      "Totale_richieste_ok_per_mese": 4,
      "Totale_richieste_ko_per_mese": 2
    },
    {
      "canale": "CANALE1",
      "tipo_operazione": "RICONTRATTUALIZZAZIONE",
      "causale": "SPONTANEA",
      "Data": "2017-03-08T00:00:00.000Z",
      "Totale_richieste_per_mese": 28,
      "Totale_richieste_ok_per_mese": 0,
      "Totale_richieste_ko_per_mese": 20
    },
    {
      "canale": "CANALE1",
      "tipo_operazione": "RICONTRATTUALIZZAZIONE",
      "causale": "SPONTANEA",
      "Data": "2017-03-09T00:00:00.000Z",
      "Totale_richieste_per_mese": 9,
      "Totale_richieste_ok_per_mese": 4,
      "Totale_richieste_ko_per_mese": 4
    }
  ]
}

Here is the VizFrame view:

<viz:VizFrame id="idVizFrame" uiConfig="{applicationSet:'fiori'}" width="100%" vizType="stacked_column" selectData="onSelectData">
											<viz:dataset>
												<viz.data:FlattenedDataset data="{/results}">
													<viz.data:dimensions>
														<viz.data:DimensionDefinition name="Causale" value="{causale}"/>
													</viz.data:dimensions>
													<viz.data:measures>
														<viz.data:MeasureDefinition name="Totale richieste OK" value="{Totale_richieste_ok_per_mese}"/>
														<viz.data:MeasureDefinition name="Totale richieste KO" value="{Totale_richieste_ko_per_mese}"/>
													</viz.data:measures>
												</viz.data:FlattenedDataset>
											</viz:dataset>
											<viz:feeds>
												<viz.feeds:FeedItem uid="valueAxis" type="Measure" values="Totale richieste OK,Totale richieste KO"/>
												<viz.feeds:FeedItem uid="categoryAxis" type="Dimension" values="Causale"/>
											</viz:feeds>
										</viz:VizFrame>

The graph shows only the first value for "ATTIVAZIONE" and the first for "SPONTANEA".

Someone could help me to understand were is the problem??

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Felipe de Mello Rodrigues Apr 13 at 12:55 AM
0

Hi Leonardo,

If you are working with CDS views you must declare your consumption view as an analytical query, this is the only way to aggregate your measures based on the selected dimensions.

Since we have the transactional and analytical paradigms in the same database you can construct CDS views for both of the scenarios, all UI5 controls dependent on analytical data (e.g. charts) needs to follow the analytical approach of development (queries, cubes, dimensions, etc).

I'm going to assume that you are working with ABAP CDS views (but HANA CDS follows the same concept), just have a look in this article explaining step by step how can you achieve this functionality: https://blogs.sap.com/2018/03/18/create-an-analytical-model-based-on-abap-cds-views/

Hope this information helps.

Cheers,

Felipe

Share
10 |10000 characters needed characters left characters exceeded