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
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
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.

Top Solution Authors