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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
sureshg2498
Advocate II
Advocate II

Measure names display as field values under a new column

Hi All,

 

We have a requirement to change the data structure where we need to display measure names as field values as shown below.

Is there any DAX code to create a new table which displays the required data structure. Could anyone please help me on this?

sureshg2498_0-1747299507506.png

 

Thanks,

Suresh.

@Bibiano_Geraldo @rajendraongole1 @Ritaf1983 @danextian  @lbendlin @Ritaf1983 @bhanu_gautam

1 ACCEPTED SOLUTION
danextian
Super User
Super User

Hi @sureshg2498 

Assuming the name of the original table is Budget, try  this:

Budget2 = 
VAR _Country = 
    DISTINCT ( Budget[Country] )  -- Get unique list of countries from the Budget table

VAR _Metric = 
    SELECTCOLUMNS ( { "Spent Budget", "Remaining Budget" }, "Metric Name", [Value] )  -- Create a table with metric names

VAR _CrossJoined = 
    CROSSJOIN ( _Country, _Metric )  -- Cross join countries with the two metric names to form all combinations

RETURN 
    ADDCOLUMNS ( 
        _CrossJoined,  -- Add a calculated column to the cross-joined table
        "Value", 
            VAR _country = [Country]  -- Current row context country
            VAR _tbl = 
                FILTER ( Budget, Budget[Country] = _country )  -- Filter Budget table for current country
            RETURN 
                SWITCH ( 
                    [Metric Name],  -- Choose logic based on metric name
                    "Spent Budget", SUMX ( _tbl, [Spent Budget] ),  -- Sum Spent Budget for the country
                    "Remaining Budget", SUMX ( _tbl, [Remaining Budget] )  -- Sum Remaining Budget for the country
                )
    )

 

danextian_0-1747309867985.png

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

7 REPLIES 7
v-csrikanth
Community Support
Community Support

Hi @sureshg2498 

Thank you for being part of the Microsoft Fabric Community.

As highlighted by @danextian @GrowthNatives @Vijay_Chethan, the proposed approach appears to effectively address your requirements. Could you please confirm if your issue has been resolve
If you are still facing any challenges, kindly provide further details, and we will be happy to assist you.

If the above information helps you, please give us a Kudos and marked the Accept as a solution.
Best Regards,
Community Support Team _ C Srikanth.

Thank you for your response Srikanth.

danextian
Super User
Super User

Hi @sureshg2498 

Assuming the name of the original table is Budget, try  this:

Budget2 = 
VAR _Country = 
    DISTINCT ( Budget[Country] )  -- Get unique list of countries from the Budget table

VAR _Metric = 
    SELECTCOLUMNS ( { "Spent Budget", "Remaining Budget" }, "Metric Name", [Value] )  -- Create a table with metric names

VAR _CrossJoined = 
    CROSSJOIN ( _Country, _Metric )  -- Cross join countries with the two metric names to form all combinations

RETURN 
    ADDCOLUMNS ( 
        _CrossJoined,  -- Add a calculated column to the cross-joined table
        "Value", 
            VAR _country = [Country]  -- Current row context country
            VAR _tbl = 
                FILTER ( Budget, Budget[Country] = _country )  -- Filter Budget table for current country
            RETURN 
                SWITCH ( 
                    [Metric Name],  -- Choose logic based on metric name
                    "Spent Budget", SUMX ( _tbl, [Spent Budget] ),  -- Sum Spent Budget for the country
                    "Remaining Budget", SUMX ( _tbl, [Remaining Budget] )  -- Sum Remaining Budget for the country
                )
    )

 

danextian_0-1747309867985.png

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Hi Danextian - I just wanted to thank you for taking the time to answer my question. Your explanation was really clear and helpful, and it gave me exactly what I needed to move forward.

 I truly appreciate the time you took to answer all of my questions and address my concerns. Thank you! 

GrowthNatives
Resolver III
Resolver III

Hi @sureshg2498 , 
i understand you are having issue with displaying measure names as field values under a new column. How I would go about is below:

 

🧮 DAX to Create the New Table

UnpivotedBudget =
UNION(
    SELECTCOLUMNS(
        BudgetTable,                   -- Replace with your actual table name
        "Country", BudgetTable[Country],
        "Metric Name", "Spent Budget",
        "Value", BudgetTable[Spent Budget]
    ),
    SELECTCOLUMNS(
        BudgetTable,
        "Country", BudgetTable[Country],
        "Metric Name", "Remaining Budget",
        "Value", BudgetTable[Remaining Budget]
    )
)


📘 Explanation

  • SELECTCOLUMNS() is used to define the new column names explicitly.

  • UNION() stacks the two versions of the table — one for Spent Budget, one for Remaining Budget.

  • Each row from the original table becomes two rows in the new table (one for each metric).

  • This is called a manual unpivot using DAX.

Result

GrowthNatives_0-1747307758889.png

Hope this solution helps you make the most of Power BI! If it did, click 'Mark as Solution' to help others find the right answers.
💡Found it helpful? Show some love with kudos 👍 as your support keeps our community thriving!
🚀Let’s keep building smarter, data-driven solutions together! 🚀 [Explore more]

Vijay_Chethan
Super User
Super User

Hello sureshg2498,
you could achieve your use case using matrix visual, using following settings:
layout ---> Tabular
values --->(Options)--->switch values to rows

Vijay_Chethan_0-1747306813770.png


if this helps, please mark as solution

 

Thank you for your response, Vijay.

Actually we need a seperate table in Power BI desktop with columns Country, Metric Name, Value.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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