Filter put on measure returning wrong result?

FlashFire

New Member
Joined
Jun 16, 2016
Messages
10
So I have this code:

Code:
KPI 2016 = SUMX(
    FILTER(
        ALL('Data Warehouse'[Sale.Invoice Date],'Data Warehouse'[EXT AMOUNT],'Data Warehouse'[Customer.Customer Name]),
        YEAR([Sale.Invoice Date]) = 2016 &&
        MONTH([Sale.Invoice Date]) <= 'LTProd Data Warehouse'[Current Last Month] &&
        MONTH([Sale.Invoice Date]) >= 'LTProd Data Warehouse'[Current First Month] &&
        IF( EXACT([Current Customer],"ALL"),
            TRUE(),
            EXACT([Customer.Customer Name],[Current Customer])
        )
    ),
[Profit])

Everything works but the IF function.
The if function is suppose to check if the measure with the value "all" or the name of the current customer, and then apply that as a filter. For what ever reason [Current Customer] doesn't return the current customer, as if the IF is applying its own filter to the measure, messing up the data.

The formula for the current customer measure is:

Code:
Current Customer = IF(HASONEVALUE('Data Warehouse'[Customer.Customer Name]),
    LASTNONBLANK('Data Warehouse'[Customer.Customer Name],TRUE()),
    "ALL")

Am I right in my conclusion? and if so, how do I make so it doesn't filter the measure when it tries to get data from it?
 
Out of pure curiosity, do you want to re-write how I would typically do this?

Code:
Total Ext Amount := SUM('Data Warehouse'[Ext Amount])

KPI 2016 := CALCULATE([Total Ext Amount], 
   FILTER(ALL('Data Warehouse'[Sale.Invoice Date]),
      YEAR([Sale.Invoice Date]) = 2016 &&
      MONTH([Sale.Invoice Date]) <= 'Data Warehouse'[Current Last Month] &&
      MONTH([Sale.Invoice Date]) >= 'Data Warehouse'[Current First Month]
   )
)

If you want to share your workbook, i would be fairly curious. Your measure looks like it should work, to me.
 
Last edited:
Upvote 0

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

Forum statistics

Threads
1,215,140
Messages
6,123,270
Members
449,093
Latest member
Vincent Khandagale

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top