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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Fragan
Helper III
Helper III

Custom total calculation for one column value

Hey,

 

I have this table :

 

image.png

 

I made a matrix visual out of it :

 

image.png


What i want to do is change the totals to :

  • For  Attribute1 keep the totals
  • For Attribute2, totals = totals/2

 

I want to change the sub-totals and grand total for one attribute.

 

Anyone can help me with that please?

1 ACCEPTED SOLUTION
Fragan
Helper III
Helper III

I found a solution :

 

 

Mesure = SUMX( 'Data'; SWITCH('Data'[attributes];
"Attribut2";IF(HASONEVALUE('Data'[date]);CALCULATE(SUM(Data[value]);Data[attributes] = "Attribut2");CALCULATE(SUM(Data[value]);Data[attributes] = "Attribut2")/2);
var a = 'Data'[attributes] return
        CALCULATE ( SUM ( 'Data'[value] );'Data'[attributes]=a)
))

 

 

View solution in original post

9 REPLIES 9
Fragan
Helper III
Helper III

I found a solution :

 

 

Mesure = SUMX( 'Data'; SWITCH('Data'[attributes];
"Attribut2";IF(HASONEVALUE('Data'[date]);CALCULATE(SUM(Data[value]);Data[attributes] = "Attribut2");CALCULATE(SUM(Data[value]);Data[attributes] = "Attribut2")/2);
var a = 'Data'[attributes] return
        CALCULATE ( SUM ( 'Data'[value] );'Data'[attributes]=a)
))

 

 

amitchandak
Super User
Super User

@Fragan 

Create a measure like that and using hasonevalue or isfiltered , use that for GT

https://powerpivotpro.com/2013/03/hasonevalue-vs-isfiltered-vs-hasonefilter/

something like this

GT Measure =sumx(Summarize(Table,Table[Attribute],"_1", sumx(Table,if(Table[Attribute] ="Attribute2" ,Table[Value]/2,Table[Value]))),[_1])

 

if(isfiltered(Table[Attribute]),sum(Table[Value]),[GT Measure])

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

@bheepatel with your solution all Attribute2 values will be divided by 12

 

@amitchandak the idea seem good, but i want also the sub total of attribute2 to change :

 

image.png

 

I want the 482 to be 241.

@Fragan Apologies - I meant to write out 2, not 12. The measure would be as below:

 

NewValue = IF(Attributes = "Attribute2", Value / 2, Value)

 

The above column will give you the values where if the Attribute is Attribute2, then it will divide the original value by 2. If it is not Attribute2, it will keep the original value as is. This should change your sub-totals and totals.

It changes the totals and the values of each Attribute2, I just want the line totals and columns totals to be changed

@Fragan , Sure You can share

 

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

@amitchandak  https://easyupload.io/0a178t , as you can see your solution is working but only for line total :

 

 

image.png

 

I want it to work for column total too, (i.e: the 482 should become 241)

 

I mean what im trying to do is to change the column subtotal of Attribute2 to (ColumnSubtotal/2)

bheepatel
Resolver IV
Resolver IV

Hi @Fragan 

 

In your first Table, you can add an additional column with the following formula:

 

NewValue = IF(Attributes = "Attribute2", Value /12, Value)

 

The above column will give you the values where if the Attribute is Attribute2, then it will divide the original value by 12. If it is not Attribute2, it will keep the original value as is. This should change your sub-totals and totals.

 

You can use the NewValue column in your matrix visual.

 

Hope that helps!

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.