Filter Context Confusion and use of CALCULATE

Purplehazed

New Member
Joined
Jul 7, 2014
Messages
13
In PowerBI I am creating some personal spending metrics. One is an average cost per meal. I am trying to
build a table the shows amount spent on grocery and an average $ per meal.

I am struggling with a measure that calculates the days in a month that will be the denominator in the $ per meal calculation.

In the pivot table pasted below and am getting 67 from the measure below. I thought that using CALCULATE in the measure
would prevent getting the same result each month i.e. the pivot tables filter would control the filter context.


I expected 28 days for Feb, 31 days for Mar and 26 days for Apr and April would go up a day each day until the end of the month then start over with May.

My date table example skips a few days so ignore 67, that number should be more like 85.


Any thoughts are appreciated!

[TABLE="width: 244"]
<colgroup><col><col><col></colgroup><tbody>[TR]
[TD]


Row Labels[/TD]
[TD]Sum of Amount[/TD]
[TD] Test[/TD]
[/TR]
[TR]
[TD]February[/TD]
[TD="align: right"](775)[/TD]
[TD="align: right"]67[/TD]
[/TR]
[TR]
[TD]March[/TD]
[TD="align: right"](898)[/TD]
[TD="align: right"]67[/TD]
[/TR]
[TR]
[TD]April[/TD]
[TD="align: right"](509)[/TD]
[TD="align: right"]67[/TD]
[/TR]
[TR]
[TD]Grand Total[/TD]
[TD="align: right"](2,181)[/TD]
[TD="align: right"]67[/TD]
[/TR]
</tbody>[/TABLE]


Test := CALCULATE(COUNTROWS(FILTER('Date','Date'[Today]>'Date'[Date])))
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
I think I figured out the problem.

I built a simple two table model to be used to ask the question. In a measure I used CALCULATE correctly (I think) but did not get the expected result. When I added a "month" column via a calculated column in the lookup date table and pulled that column into the pivot table I got this (below).

[TABLE="width: 245"]
<colgroup><col><col><col></colgroup><tbody>[TR]
[TD]Row Labels[/TD]
[TD]Sum of Amount[/TD]
[TD] Test[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD="align: right"](775)[/TD]
[TD="align: right"]20[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD="align: right"](898)[/TD]
[TD="align: right"]27[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD="align: right"](509)[/TD]
[TD="align: right"]20[/TD]
[/TR]
[TR]
[TD]Grand Total[/TD]
[TD="align: right"](2,181)[/TD]
[TD="align: right"]67[/TD]
[/TR]
</tbody>[/TABLE]



Any explanation of what I've done and/or not done correctly in non-programmer language would still be much appreciated.

I am determined to learn DAX!!!! Very powerful!
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

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