MAXDate returns max date of dimension not FACT table (DAX)

CLEARIFY

New Member
Joined
Oct 2, 2011
Messages
11
FACT table with link to Date Dimension in star schema fashion.


Date Dimension holds 20 years of dates, linked to fact table by Integer primary and foreign key fields.


Have designated date dimension as 'date table' in model, with transaction date being the 'date field' (And tried without).


I have tried various forms of Max Date or Last Date to get the latest date of a transaction in the fact table, but I always get the last date in the date dimension table
Simple would be: =MAX('Calendar - Transaction Date'[Transaction Date])

Using Max Date in a regular pivot table produces the correct results:
regular_pivot_table.jpg


Using Max Date in a PowerPivot produces different results:
powerpivot_table.jpg


Lastly bringing in the maxdate in a powerpivot table removes the filters I have set for the powerpivot report.
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
You need a little bit more filtering on your formula to make it work as a Calculated Column in your Fact table.

You should read up on filter context vs. row context. Many DAX formulas will behave differently when used as a Measure vs. when used as a Calculated Column.

To make your formula work as a Calculated Column, you must wrap it in a CALCULATE() with an additional filter that checks for earlier occurrences of the product on the fact table:

Code:
=CALCULATE(
                         MAX('Calendar - Transaction Date'[Transaction Date]),
                         FILTER(
                              'FACTS',
                              'FACTS'[Product Name or ID] = EARLIER('FACTS'[Product Name or ID])
                         )
               )

If your FACT table is really big, this will take a while to process and you might be better off just leaving MaxDate as a measure and not trying to make a Calculated Column out of it.
 
Upvote 0
You need a little bit more filtering on your formula to make it work as a Calculated Column in your Fact table.

You should read up on filter context vs. row context. Many DAX formulas will behave differently when used as a Measure vs. when used as a Calculated Column.

To make your formula work as a Calculated Column, you must wrap it in a CALCULATE() with an additional filter that checks for earlier occurrences of the product on the fact table:

Code:
=CALCULATE(
                         MAX('Calendar - Transaction Date'[Transaction Date]),
                         FILTER(
                              'FACTS',
                              'FACTS'[Product Name or ID] = EARLIER('FACTS'[Product Name or ID])
                         )
               )

If your FACT table is really big, this will take a while to process and you might be better off just leaving MaxDate as a measure and not trying to make a Calculated Column out of it.

I received some help from a Marco Russo in another forum, but it relies on the fact that I created a RELATED column in the FACT table to have a date; There are issues with the date dimension that I am still investigating - its behavior is odd; but for a later day. I will share the results here of what I got to work:

For maximum date for any given row label context: CALCULATE ( MAX ( 'FactTable'[Related Date Field Column] ), FactTable )

For maximum date for the whole table regardless of context: CALCULATE ( MAX ( 'FactTable'[Related Date Field Column] ), FILTER ( ALL ( FactTable ), TRUE ) )
 
Upvote 0

Forum statistics

Threads
1,223,952
Messages
6,175,595
Members
452,656
Latest member
earth

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