DAX - limiting DATEsYTD to entities present in the selected month

gsw811

New Member
Joined
Sep 11, 2014
Messages
5
I'm using DATESYTD to produce a YTD count of the number of Falls (eg FallYTD:=Calculate(SUM([Falls],DatesYTD(tablename[Date])) The issue I'm encountering is that I want the YYD metric calculated only on the entities that provide data for the selected month. For example
[TABLE="width: 500"]
<tbody>[TR]
[TD]A
[/TD]
[TD]10[/TD]
[TD]Jan[/TD]
[/TR]
[TR]
[TD]B[/TD]
[TD]15[/TD]
[TD]Jan
[/TD]
[/TR]
[TR]
[TD]C[/TD]
[TD]20[/TD]
[TD]Jan[/TD]
[/TR]
[TR]
[TD]D[/TD]
[TD]25[/TD]
[TD]Jan[/TD]
[/TR]
[TR]
[TD]E[/TD]
[TD]30[/TD]
[TD]Feb[/TD]
[/TR]
</tbody>[/TABLE]

[TABLE="width: 500"]
<tbody>[TR]
[TD]C[/TD]
[TD]10[/TD]
[TD]Feb[/TD]
[/TR]
[TR]
[TD]D[/TD]
[TD]20[/TD]
[TD]Feb[/TD]
[/TR]
[TR]
[TD]E[/TD]
[TD]30[/TD]
[TD]Feb[/TD]
[/TR]
</tbody>[/TABLE]

The YTD total I'm getting for Feb is 160
The YTD total I want for Feb is 135 i.e. based on only those entities present in the month (C, D, E)

If for example March only had E=30 then I would want the YTD to show 90.

Please help. Thanks,
Gregg
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
You just need to add VALUES( tablename[Entity]) (or whatever the column is called) as a second filter argument to CALCULATE, to filter on those values in the current filter context:
Code:
FallYTD :=CALCULATE (
    SUM ( [Falls] ),
    DATESYTD ( tablename[Date] ),
[B][COLOR=#ff0000]    VALUES ( tablename[Entity] )[/COLOR][/B]
)
 
Upvote 0

Forum statistics

Threads
1,224,115
Messages
6,176,479
Members
452,729
Latest member
fizzay_pop

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