Unable to display json array of objects data with different fields

Answered
Akshay Alva asked on August 9, 2021

Hi,
We are trying to display month data for a rolling year starting from the current month. Our json response that we are sending to the pivot is as attached. However the pivot considers only the first element in the array to form the slice (measures) - attached screen shot of the pivot table.
 
Can you help us in finding a solution to display the current month till Dec under current year (2021) and the remaining months (Jan to current month -1) in the next year (2022)? Data in json is as per this structure (please see attached).
 
Thanks.

Attachments:
output.JPG
report(3).json

2 answers

Public
Vera Didenko Vera Didenko Flexmonster August 10, 2021

Hello,
 
Thank you for reaching out.
 
To achieve the described visualization, we suggest creating a separate "Month" field instead of using a separate measure for each month.
Such an approach would allow displaying different months under each year.
 
We have prepared a JSFiddle for illustration: https://jsfiddle.net/flexmonster/cdez2j61/.
In the example, we preprocessed the data a bit in the following way:
From this format:

[
{
"id": "FOID_411F9462-4A0F-482F-8335-12820B07090A",
"FinancialYear": 2021,
"ProductName": "Potash",
"MarketerName": "Admin Bhagin",
"ProductCategoryName": "Paper Crafts & Hand",
"LocationName": "Bangalore",
"CustomerName": "Emisha Tech",
"Aug": 0,
"Sep": 10,
"Oct": 0,
"Nov": 5,
"Dec": 8
}
]

To the following:

[
{
"id": "FOID_411F9462-4A0F-482F-8335-12820B07090A",
"FinancialYear": 2021,
"Month": "Aug",
"ProductName": "Potash",
"MarketerName": "Admin Bhagin",
"ProductCategoryName": "Paper Crafts & Hand",
"LocationName": "Bangalore",
"CustomerName": "Emisha Tech",
"Aug": 0,
"Sep": 0,
"Oct": 0,
"Nov": 0,
"Dec": 0,
"Value": 0
},
{
"id": "FOID_411F9462-4A0F-482F-8335-12820B07090A",
"FinancialYear": 2021,
"Month": "Sep",
"ProductName": "Potash",
"MarketerName": "Admin Bhagin",
"ProductCategoryName": "Paper Crafts & Hand",
"LocationName": "Bangalore",
"CustomerName": "Emisha Tech",
"Aug": 0,
"Sep": 10,
"Oct": 0,
"Nov": 0,
"Dec": 0,
"Value": 10
},
{
"id": "FOID_411F9462-4A0F-482F-8335-12820B07090A",
"FinancialYear": 2021,
"Month": "Oct",
"ProductName": "Potash",
"MarketerName": "Admin Bhagin",
"ProductCategoryName": "Paper Crafts & Hand",
"LocationName": "Bangalore",
"CustomerName": "Emisha Tech",
"Aug": 0,
"Sep": 0,
"Oct": 0,
"Nov": 0,
"Dec": 0,
"Value": 0
},
...
]

 
Please let us know if this helps.
Feel free to reach out should other questions arise.
 
Kind regards,
Vera

Public
Akshay Alva August 10, 2021

Hi Vera,
Thank you for your response! This helps.
 
Warm Regards,
Akshay

Please login or Register to Submit Answer