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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
AGo
Post Patron
Post Patron

remove filter complicated case issue

Hello,

I've got this PBIX 

and this measure 

Measure = (CALCULATE(SUM('Table'[Value]);'Table'[Type1]<>"REVENUE")*-1)/CALCULATE(SUM('Table'[Value]);'Table'[Type1]="REVENUE")

that I'd like to correct in order to divide costs (in every hierarchy level) with whatever value I obtain under total REVENUE from my filter visual selection.

By design Type 3 column could have a value that has a value as cost, revenue, both or none.

 

I tried changing calculate argument with filter function but without success. Is it possible?

Thanks in advance

1 ACCEPTED SOLUTION
harshnathani
Community Champion
Community Champion

Hi @AGo ,

 

Your requirement is not very clear. However, you can try this measure.

 

Measure =
var __nrt1 = CALCULATE(SUMX('Table','Table'[Value]),FILTER(ALL('Table'),'Table'[Type1] <> "Revenue"))
var __rt1 = CALCULATE(SUMX('Table','Table'[Value]),FILTER(ALL('Table'),'Table'[Type1] = "Revenue"))
var __nrt2 = CALCULATE(SUMX('Table','Table'[Value]),FILTER(ALLEXCEPT('Table','Table'[Type2]),'Table'[Type1] <> "Revenue"))
var __rt2 = CALCULATE(SUMX('Table','Table'[Value]),FILTER(ALL('Table'),'Table'[Type1] = "Revenue"))
var __rt3 = CALCULATE(SUMX('Table','Table'[Value]),FILTER(ALLEXCEPT('Table','Table'[Type3]),'Table'[Type1] = "Revenue"))
var __nrt3 = CALCULATE(SUMX('Table','Table'[Value]),FILTER(ALLEXCEPT('Table','Table'[Type2],'Table'[Type3]),'Table'[Type1] <> "Revenue"))
var __t1inscope = ISINSCOPE('Table'[Type1])
var __t2inscope = ISINSCOPE('Table'[Type2])
var __t3inscope = ISINSCOPE('Table'[Type3])

return

switch(
true(),
__t3inscope,DIVIDE(__nrt3,__rt3),
__t2inscope,DIVIDE(__nrt2,__rt2),
__t1inscope,DIVIDE(__nrt1,__rt1)
)
 
sc1.PNG 
 
sc2.PNG
 
sc3.PNG
 
Regards,
Harsh 
 
If I resolve your problem Mark it as a solution and give kudos.

View solution in original post

4 REPLIES 4
harshnathani
Community Champion
Community Champion

Hi @AGo ,

 

Your requirement is not very clear. However, you can try this measure.

 

Measure =
var __nrt1 = CALCULATE(SUMX('Table','Table'[Value]),FILTER(ALL('Table'),'Table'[Type1] <> "Revenue"))
var __rt1 = CALCULATE(SUMX('Table','Table'[Value]),FILTER(ALL('Table'),'Table'[Type1] = "Revenue"))
var __nrt2 = CALCULATE(SUMX('Table','Table'[Value]),FILTER(ALLEXCEPT('Table','Table'[Type2]),'Table'[Type1] <> "Revenue"))
var __rt2 = CALCULATE(SUMX('Table','Table'[Value]),FILTER(ALL('Table'),'Table'[Type1] = "Revenue"))
var __rt3 = CALCULATE(SUMX('Table','Table'[Value]),FILTER(ALLEXCEPT('Table','Table'[Type3]),'Table'[Type1] = "Revenue"))
var __nrt3 = CALCULATE(SUMX('Table','Table'[Value]),FILTER(ALLEXCEPT('Table','Table'[Type2],'Table'[Type3]),'Table'[Type1] <> "Revenue"))
var __t1inscope = ISINSCOPE('Table'[Type1])
var __t2inscope = ISINSCOPE('Table'[Type2])
var __t3inscope = ISINSCOPE('Table'[Type3])

return

switch(
true(),
__t3inscope,DIVIDE(__nrt3,__rt3),
__t2inscope,DIVIDE(__nrt2,__rt2),
__t1inscope,DIVIDE(__nrt1,__rt1)
)
 
sc1.PNG 
 
sc2.PNG
 
sc3.PNG
 
Regards,
Harsh 
 
If I resolve your problem Mark it as a solution and give kudos.

Your solution worked like a charm for costs! Thanks. The only strange fact is that the measure gives a result of 76% under REVENUE that should be totalrevenue/totalrevenue=x/x=1=100% or better hidden

harshnathani
Community Champion
Community Champion

 

Hi @AGo ,

 

Thanks that you liked the solution.

 

Please use this formula for __nrt1. This will remove the 77% from Revenue.

 

var __nrt1 = CALCULATE(SUMX('Table','Table'[Value]),FILTER('Table','Table'[Type1] <> "Revenue"))
 
Thanks and Regards,
Harsh Nathani
camargos88
Community Champion
Community Champion

Hi @AGo ,

 

I didn't get exaclty what you want to do. But perhaps it should work:

 

Measure = CALCULATE(SUM('Table'[Value]);'Table'[Type1]<>"REVENUE")*-1/CALCULATE(SUM('Table'[Value]); FILTER(ALL('Table'); 'Table'[Type1]="REVENUE"))
 
Give it a shoot and let me know, if no give us some example.
 
Ricardo


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

Proud to be a Super User!



Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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