Implementing pivotComparator function in streamlit with pivot table

The idea to reverse order of pivot columns (date) as desc.
I found that for pivoted column I have to use pivotComparator which is function to implement.
can anyone give an example how to set it up?

As example, if we have dataframe with dates 2024-01 2024-02 2024-03 and pivot that frame with data column, it will be ordered asc by default. I would like to see the order as 2024-03 2024-02 …

my not working example:

js_code = JsCode("""
function (a, b) {
    return Number(a) - Number(b);
}
""")

gb.configure_column(field='date', header_name='date', width=100, pivot=True, enablePivot=True,
                    type=["customDateTimeFormat"], custom_format_string='yyyy-MM', rowGroup=False, hide=False,
                    pivotComparator=js_code)

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.