Filtering a calculated total

alt731

New Member
Joined
Jun 28, 2017
Messages
3
I have a table of data that looks like this:

IDBTypeQtyTypeTotalDate
1B1112016-06-01
2B2132016-06-01
3B2132016-07-20
4B2132016-08-28
5B3112016-06-20

<tbody>
</tbody>




I'm using DAX to create the TypeTotal column above. It is effectively doing a SUMIF, and then producing a total quantity for the specific BType and sticking it in the TypeTotal column.

TypeTotal = CALCULATE(SUM(Query1[Qty]), FILTER(Query1, Query1[BType] = EARLIER (Query1[BType])))

Note that if you total up the Qty for B2 in the table, it comes to 3, which is why TypeTotal is showing 3. This is exactly what I want.

However, I also want the TypeTotal column to be responsive to a date filter.

I can drag in a filter to filter on Date, and lets say I set it to between 2016-07-01 to current. In this case, the row with ID of 2 will be filtered out, which is again, exactly what I want. But the TypeTotal column for ID rows 3 and 4 still displays 3 (i.e. the total for B3 in the whole table) not the total for B3 on the filtered data set. This is not what I want.

How do I go about getting the TypeTotal column to change its total based on the date filter?
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Calculated columns are computed at data refresh/load time not at run time. So even if you put a filter on 'Date', the column is not recomputed. Only measures are recomputed at run time. How your measure function is written depends on what you want your pivot to look like.
 
Upvote 0

Forum statistics

Threads
1,214,883
Messages
6,122,077
Members
449,064
Latest member
MattDRT

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