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
Anonymous
Not applicable

Exclude particular row in total

Hi,

 

I am trying to show a table where in a Matrix, the total excludes Year1, where my Total would be 4400 instead of 4900 and yet Year1 data is still there.

I used this measure, but it removed the 'Year1' cause there's no value anymore.

 

Total = CALCULATE(SUM('Table'[Amount]),FILTER('Table','Table'[Table (Year)] <>"Year1"))

 Capture.PNG

1 ACCEPTED SOLUTION
Zubair_Muhammad
Community Champion
Community Champion

Hi @Anonymous 

 

Try this measure

 

Spoiler
Measure =
IF (
    HASONEFILTER ( 'Table'[Year] ),
    SUM ( 'Table'[Amount] ),
    SUMX (
        FILTER ( VALUES ( Table[Year] ), 'Table'[Year] <> "Year1" ),
        CALCULATE ( SUM ( 'Table'[Amount] ) )
    )
)

 

 


Regards
Zubair

Please try my custom visuals

View solution in original post

3 REPLIES 3
Zubair_Muhammad
Community Champion
Community Champion

Hi @Anonymous 

 

Try this measure

 

Spoiler
Measure =
IF (
    HASONEFILTER ( 'Table'[Year] ),
    SUM ( 'Table'[Amount] ),
    SUMX (
        FILTER ( VALUES ( Table[Year] ), 'Table'[Year] <> "Year1" ),
        CALCULATE ( SUM ( 'Table'[Amount] ) )
    )
)

 

 


Regards
Zubair

Please try my custom visuals
Anonymous
Not applicable

@Zubair_Muhammad  It worked!! Can you explain a little for me please?

I am trying to piece together how each formula works. Individually, I kinda understand, but putting them together seems a bit confusing... Sorry..

Sure @Anonymous 

 

The formulas like HASONEFILTER,HASONEVALUE,ISFILTERED are useful in detecting totals and specifying different calculations for them.
The total row contains all the years you have selected

Here is a very good article

 

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

 

So in the if clause we apply the normal sum(sales) calculation if the YEAR row contains a single year.
In the totalrow we sum the sales of all the years (excluding an year) using an interator function SUMX


Regards
Zubair

Please try my custom visuals

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.