Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Hussein_charif
Helper III
Helper III

automatically add new pivoted column to table visual

i have a table containing pivoted columns. i want a measure to display in a table visual all the pivoted columns's sum. for example, i could have a column called transport, i display the sum of that column, and so on.. the pivoted column is called charge, so i created a distinct table to get the distinct values of that column charge, so when the data is updated and a new value is added to the column, it shows in the distinct table, and it shows as well in the pivoted table. so i want a measure to check where the columns names in my table are equal to the values in my distinct table, and do the sum for those columns to display them dynamically without needing to add them each time to my field parameter or visual

2 REPLIES 2
v-jtian-msft
Community Support
Community Support

Hi,@Hussein_charif .I am glad to help you.
By pivot columns, do you mean change from rows to columns?
Pivot columns feature description - Power Query | Microsoft Learn
like this?

vjtianmsft_0-1738031686702.png


this is my test data.
Assuming that your original data before transposition looked like this (no columns were transposed, so you could just create a measure to count each column)

vjtianmsft_1-1738031714938.pngvjtianmsft_2-1738031725692.png

Or create a measure via the Distinct table you mentioned.

vjtianmsft_3-1738031758337.png

DynamicSum = 
    VAR _chargeTypes = MAX('DistinctChargeTypes'[ChargeType])
    VAR _chargetable = VALUES(DistinctChargeTypes[ChargeType])
    VAR _total = SUMX(
        ALL(SalesData),
        [Amount]
    )
    VAR _values = SUMX(
        _chargetable,
        CALCULATE(
            SUM(SalesData[Amount]),
            SalesData[ChargeType] = _chargeTypes
        )
    )
    RETURN
        IF(
            ISINSCOPE('DistinctChargeTypes'[ChargeType]),
            _values,
            _total
        )

If my understanding is wrong, please let me know and provide me with the corresponding pbix file detailing what you did and a screenshot of the expected result.(Share to forum via github link)

I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
Best Regards,
Carson Jian,
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

hi @v-jtian-msft , thank you for the reply. so lets consider your data, my Columns are the "ChargeType" column's values, after i pivoted the column on my "Amount" column, so now each ChargeType value is a column that has the  corresponding Amount. what i want is a measure, or maybe if it is done by a field parameter, so that if different ChargeTypes are added, to be automatically added in my table visual

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.