Bug: Function Backed Pivot Table - Totals

I wrote this simple identical code in a Functions V1 code repo and a Functions V2 code repo. Like described in your Documentation

interface SalesData {
    region: string;
    year: string;
    productType?: string;
    values: {
        totalSales: Integer;
    }
};



    @Function()
    public testPivotExpandableNew(): SalesData[] {
        return [
            {
            "region": "NA",
            "year": "2021",
            "values": {
                "totalSales": 30000
            }
        },
            {
                "region": "NA",
                "year": "2021",
                "productType": "Clothing",
                "values": {
                    "totalSales": 90000
                }
            },
            {
                "region": "NA",
                "year": "2021",
                "productType": "Electronics",
                "values": {
                    "totalSales": 150000
                }
            },
            {
                "region": "NA",
                "year": "2021",
                "productType": "Furniture",
                "values": {
                    "totalSales": 60000
                }
            }
        ];
    }

The Function Published by the V1 repo renders the correct result while the V2 version wont show the totals:

Please let me know if I did something wrong here or if it’s really a bug.

Hi! Could you share the code for you v2 function? It looks like the value for the total group may be set explicitly as null rather than not be included.

Hi,

Thanks for your help in this matter.

I started a new V2 Functions repository, posted there again exactly the same code and then the issue was resolved.

Looks like it was/is an issue with older V2 Functions versions.

Ah okay good to know it’s no longer affecting – let use know if this comes up again!

Hi,

I face the same problem, but when using Python code. Here is my Python code, which replicates the logic of the TypeScript function

from functions.api import function
from typing import List, Optional
from dataclasses import dataclass

@dataclass
class Values:
    totalSales: int

@dataclass
class SalesData:
    region: str
    year: str
    values: Values
    productType: Optional[str] = None

@function
def pivot_expandable() -> List[SalesData]:
    return [
        SalesData(region="NA", year="2021", values=Values(totalSales=30000)),
        SalesData(region="NA", year="2021", productType="Clothing", values=Values(totalSales=90000)),
        SalesData(region="NA", year="2021", productType="Electronics", values=Values(totalSales=150000)),
       SalesData(region="NA", year="2021", productType="Furniture", values=Values(totalSales=60000))]

As a result, I get this pivot table

Question:

How can I prevent ‘null’ from appearing as a dimension when using Python code?