Forum Discussion
Lakshmi123
1 year agoNew Member
Get an Latest date Records
Hi , i created below table by using 3 tables : dim TableA- state fact TableB- num (num of records), diff(measure) dim TableC- date_dt state num diff date_dt alabama 1000 100 20-F...
- 1 year ago
Hi,
I tried to create a sample pbix file like below, and please check the below picture and the attached pbix file.
I used INDEX dax function in the measures.
INDEX function (DAX) - DAX | Microsoft Learn
Num expected result: = VAR _t = CALCULATETABLE ( SUMMARIZE ( 'fact', 'calendar'[Date] ), REMOVEFILTERS ( 'calendar'[Date] ) ) VAR _latestdate = INDEX ( 1, _t, ORDERBY ( 'calendar'[Date], DESC ) ) RETURN IF ( HASONEVALUE ( state[state] ), CALCULATE ( SUM ( 'fact'[num] ), KEEPFILTERS ( 'calendar'[Date] = _latestdate ) ) )Diff expected result: = VAR _t = CALCULATETABLE ( SUMMARIZE ( 'fact', 'calendar'[Date] ), REMOVEFILTERS ( 'calendar'[Date] ) ) VAR _latestdate = INDEX ( 1, _t, ORDERBY ( 'calendar'[Date], DESC ) ) RETURN IF ( HASONEVALUE ( state[state] ), CALCULATE ( SUM ( 'fact'[diff] ), KEEPFILTERS ( 'calendar'[Date] = _latestdate ) ) )
Jihwan_Kim
Super User
1 year agoHi,
I tried to create a sample pbix file like below, and please check the below picture and the attached pbix file.
I used INDEX dax function in the measures.
INDEX function (DAX) - DAX | Microsoft Learn
Num expected result: =
VAR _t =
CALCULATETABLE (
SUMMARIZE ( 'fact', 'calendar'[Date] ),
REMOVEFILTERS ( 'calendar'[Date] )
)
VAR _latestdate =
INDEX ( 1, _t, ORDERBY ( 'calendar'[Date], DESC ) )
RETURN
IF (
HASONEVALUE ( state[state] ),
CALCULATE (
SUM ( 'fact'[num] ),
KEEPFILTERS ( 'calendar'[Date] = _latestdate )
)
)
Diff expected result: =
VAR _t =
CALCULATETABLE (
SUMMARIZE ( 'fact', 'calendar'[Date] ),
REMOVEFILTERS ( 'calendar'[Date] )
)
VAR _latestdate =
INDEX ( 1, _t, ORDERBY ( 'calendar'[Date], DESC ) )
RETURN
IF (
HASONEVALUE ( state[state] ),
CALCULATE (
SUM ( 'fact'[diff] ),
KEEPFILTERS ( 'calendar'[Date] = _latestdate )
)
)