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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
dgibson
Frequent Visitor

Dynamic Column Name in Matrix base on a measure name

I have a set of data that uses measures that I want to group into sections in a Matrix.

 

The source data looks like:

  Location

  CurrentYearSales

  Prior Year Sales

  CurrentYearGuestCount

  PriorYearGuest Count

 

I have 2 measures  

  1) CompSalesPercent = (currentYearSales -PriorYearSales) / PriorYearSales

  2) CompGuestPerenct = (currentYearGuest - priorYearGuest) / priorYearGuest

 

I want to build a a measure based on the measure name that will be a heading column in the Matrix (Sales and Traffic) to group the data together.

 

It would look like:

 

                 Sales                            Traffic

location    CompSalesPercent       CompGuestPercent

1                 3.4                                 2.1

2                 2.8                                2.6

 

Is there any way to build a measure or column based on the name of the Measure

 

Thanks

 

David

3 REPLIES 3
v-yulgu-msft
Employee
Employee

Hi @dgibson,

 

For measures, it is not possible to add a group header based on measures in Matrix.

 

As a workaround, you should get the CompSalesPercent and CompGuestPerenct values via calculated columns. In this scenario, please generate a calculated table like below:

Table 2 =
UNION (
    SELECTCOLUMNS (
        'Table 1',
        "Location", 'Table 1'[Location],
        "Type", "Sales",
        "Name", "CompSalesPercent",
        "Value", ( 'Table 1'[CurrentYearSales] - 'Table 1'[PriorYearSales] )
            / 'Table 1'[PriorYearSales]
    ),
    SELECTCOLUMNS (
        'Table 1',
        "Location", 'Table 1'[Location],
        "Type", "Traffic",
        "Name", "CompGuestPercent",
        "Value", ( 'Table 1'[CurrentTearGuestCount] - 'Table 1'[PriorYearGuestCount] )
            / 'Table 1'[PriorYearGuestCount]
    )
)

1.PNG

 

Use a matrix to place fields from above table. Drill down to the bottom level.

2.PNG

 

Best regards,

Yuliana Gu

 

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

This only works if you dont have rollups at the row level, where the values raw values are need to calculate the measure.  Ie.  2 locations that have compSales of 1% do not rollup to comp Sales of 2%.  I was trying to avoid this, because this is a large dataset with multiple measures (example was simplified) and will need to load the the low level multiple times for each 'Type' in your example.

 

Thanks

 

 

 

 

dgibson
Frequent Visitor

I have a set of data that uses measures that I want to group into sections in a Matrix.

 

The source data looks like:

  Location

  CurrentYearSales

  Prior Year Sales

  CurrentYearGuestCount

  PriorYearGuest Count

 

I have 2 measures  

  1) CompSalesPercent = (currentYearSales -PriorYearSales) / PriorYearSales

  2) CompGuestPerenct = (currentYearGuest - priorYearGuest) / priorYearGuest

 

I want to build a a measure based on the measure name that will be a heading column in the Matrix (Sales and Traffic) to group the data together.

 

It would look like:

 

                 Sales                            Traffic

location    CompSalesPercent       CompGuestPercent

1                 3.4                                 2.1

2                 2.8                                2.6

 

Is there any way to build a measure or column based on the name of the Measure

 

Thanks

 

David

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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