cancel
Showing results for
Did you mean:

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a \$100 discount. Register Now

Frequent Visitor

## Matrix from unpivoted table - how use different methods of grandtotal calclulating

Hi!

I have unpivoted table like:

 Product Measure Unit Value Product 1 Price USD 1000 Product 1 Remains tn 10 Product 1 Competitor Price USD 1050 Product 2 Price USD 1060 Product 2 Remains tn 15 Product 2 Competitor Price USD 1100 Product 3 Price USD 1060 ... ... ... ...

So, I use matrix for visualize this info. I can't use pivot table because of more then 50 measures.

But in grandtotals I need to calculate the sum for tn-values and average for price-values.

Is there are the way to do this? Or I will be forced to use pivoted table and prescribe the calculation rule for each measure?

I have already tried to pivot measure via their parent groups (remains and price), but this way make visualization unpretty and unreadable

1 ACCEPTED SOLUTION
Community Champion

Hi @Fatman121 ,

Start by creating a measure for each logic:

``Remains = SUM(Table[Value])``
``Price = AVERAGE(Table[Value])``

Then create a final measure that switches between the other measures, depending on the value of your "Measure" column.

``````Dynamic selection =
SWITCH( SELECTEDVALUE( Table[Measure] ) ,
"Price" , [Price] ,
"Remains" , [Remains]
)``````

When you use the "Measure" column as the row dimension you should get the different types of logic while only having to use the single "Dynamic selection" measure as the value in the matrix.

Hope this helps!

Br,
J

2 REPLIES 2
Frequent Visitor

@tex628  I am very grateful for your help!

Community Champion

Hi @Fatman121 ,

Start by creating a measure for each logic:

``Remains = SUM(Table[Value])``
``Price = AVERAGE(Table[Value])``

Then create a final measure that switches between the other measures, depending on the value of your "Measure" column.

``````Dynamic selection =
SWITCH( SELECTEDVALUE( Table[Measure] ) ,
"Price" , [Price] ,
"Remains" , [Remains]
)``````

When you use the "Measure" column as the row dimension you should get the different types of logic while only having to use the single "Dynamic selection" measure as the value in the matrix.

Hope this helps!

Br,
J

Announcements

#### Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

#### Power BI Monthly Update - February 2024

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

#### Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

#### Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors
Top Kudoed Authors