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

Measure total ignoring filter

Hello I've got 3 tables

 

Table A = Facts has sales

Table B = Forecast has forecasts

Table C = Calander table

 

Sales are indivdual, Forecasts are monthly first of the month, and Calander is date.

 

They are linked by the calander table 1 too many

 

Maand = month, Netto Afzet = sales, Netto Forecast = forecast

Teun_0-1607524730245.png

I got this table and what i want is this.

Teun_1-1607524826328.png

But this is done with manual filter, and i want these totals in a card. I also need them for other calculations.

So i made 2 measures. 1 for the forast and 1 for the sales. I only want the rows that have forecasts.

Afzet =
CALCULATE(SUM(Facts[NettoAfzet]), FILTER(Calander, SUM(Forecast[dDemandKg]) > 0))
 
 
This returns the correct months, but my total is the grandtotal of sales of all months.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a6ed0b7a1b53a88d7b19937e1f6e59b4.png

How do I fix my measure to display these totals correct for my sales aswel. Thanks up front.

 
 

 

 

 

 

 

2 ACCEPTED SOLUTIONS
AlB
Community Champion
Community Champion

Hi @Anonymous 

Afzet V2 =
SUMX (
    FILTER (
        DISTINCT ( Calander[Maand] ),
        CALCULATE ( SUM ( Forecast[dDemandKg] ) ) > 0
    ),
    CALCULATE ( SUM ( Facts[NettoAfzet] ) )
)

 If you have more than one field (Maand) in the rows of the table visual, you might have to add it to the first argument of FILTER( )

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

View solution in original post

AlB
Community Champion
Community Champion

@Anonymous 

I'd need to see the complete model to give a fully accurate answer but:

Your code works well at the individual rows of the visual (not total) because filter context restricts the SUM( ) to the current month. At the total, however, you have no month in the filter context and therefore the SUM(Forecast...) is done for the full year (since you have that selected). That is > 0 and therefore SUM(Facts..) is run over the whole year

 

The provided solution basically reenacts step by step what happens in the visual. At the total, it checks, month by month, whether the forecast demand is > 0  and if so adds up the SUM(Facts...) for that month. Note the important role context transition plays here. At the individual rows, it does the same but restricted to the current month in the filter context.            

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

View solution in original post

4 REPLIES 4
AlB
Community Champion
Community Champion

@Anonymous 

I'd need to see the complete model to give a fully accurate answer but:

Your code works well at the individual rows of the visual (not total) because filter context restricts the SUM( ) to the current month. At the total, however, you have no month in the filter context and therefore the SUM(Forecast...) is done for the full year (since you have that selected). That is > 0 and therefore SUM(Facts..) is run over the whole year

 

The provided solution basically reenacts step by step what happens in the visual. At the total, it checks, month by month, whether the forecast demand is > 0  and if so adds up the SUM(Facts...) for that month. Note the important role context transition plays here. At the individual rows, it does the same but restricted to the current month in the filter context.            

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

AlB
Community Champion
Community Champion

Hi @Anonymous 

Afzet V2 =
SUMX (
    FILTER (
        DISTINCT ( Calander[Maand] ),
        CALCULATE ( SUM ( Forecast[dDemandKg] ) ) > 0
    ),
    CALCULATE ( SUM ( Facts[NettoAfzet] ) )
)

 If you have more than one field (Maand) in the rows of the table visual, you might have to add it to the first argument of FILTER( )

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

Anonymous
Not applicable

Hey AIB,

 

That worked great thanks. Any explenation as to why my old way yielded the wrong results?

It didn't occur to me that having the month num multiple times would affect the outcome since I had year selected in filter context outside the measure.   

  

Anyway, thanks again!

negi007
Community Champion
Community Champion

@Anonymous Have you tried using the Sumx function. Refert to this link

 

https://powerpivotpro.com/2012/03/subtotals-and-grand-totals-that-add-up-correctly/?nabm=0&utm_referrer=https%3A%2F%2Fwww.google.com%2F

 

Alternativly, will it be possible for you to share your powerbi file.




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



Proud to be a Super User!


Follow me on linkedin

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.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors