Forum Discussion
How to write DAX to filter only specific rows dynamically even when data is changed in the future.
- 4 years ago
Hi,
Sorry for my misunderstanding.
Please try the below.
Estimated measure: =
VAR newtable =
FILTER (
SUMMARIZE ( ALL ( Data ), 'Calendar'[Date], Data[Type] ),
AND ( Data[Type] <> "Actual", Data[Type] <> "Current" )
)
VAR groupbymindate =
GROUPBY (
newtable,
Data[Type],
"@mindate", MINX ( CURRENTGROUP (), 'Calendar'[Date] )
)
VAR filter_table =
FILTER (
CALCULATETABLE ( Data, TREATAS ( groupbymindate, Data[Type], Data[Date] ) ),
Data[Type] = MAX ( Data[Type] )
&& Data[Date] IN VALUES ( 'Calendar'[Date] )
)
VAR monthyeartable =
SUMMARIZE (
ADDCOLUMNS (
SUMMARIZE ( Data, 'Calendar'[Month & Year], Data[Type] ),
"@result",
CALCULATE (
IF (
SELECTEDVALUE ( Data[Type] ) = "Current",
SUM ( Data[Estimated] ),
SUMX ( filter_table, Data[Estimated] )
)
)
),
'Calendar'[Month & Year],
[@result]
)
RETURN
IF (
HASONEVALUE ( 'Calendar'[Month & Year] ),
SUMX ( monthyeartable, [@result] )
)
Hi,
I tried to follow the concept and created a sample pbix file like attached.
Please check the below picture and the attached pbix file.
Estimated measure: =
VAR newtable =
FILTER (
SUMMARIZE ( ALL ( Data ), 'Calendar'[Date], Data[Type] ),
AND ( Data[Type] <> "Actual", Data[Type] <> "Current" )
)
VAR groupbymindate =
GROUPBY (
newtable,
Data[Type],
"@mindate", MINX ( CURRENTGROUP (), 'Calendar'[Date] )
)
VAR filter_table =
FILTER (
CALCULATETABLE ( Data, TREATAS ( groupbymindate, Data[Type], Data[Date] ) ),
Data[Type] = MAX ( Data[Type] )
&& Data[Date] IN VALUES ( 'Calendar'[Date] )
)
RETURN
IF (
HASONEVALUE ( 'Calendar'[Month & Year] ),
IF (
SELECTEDVALUE ( Data[Type] ) = "Current",
SUM ( Data[Estimated] ),
SUMX ( filter_table, Data[Estimated] )
)
)
- Anonymous4 years agoNot applicable
Thank you very much Jihwan_Kim that's a great solution.
But the line chart is broken with the points. Please see below
Thanks
Dee
- Jihwan_Kim4 years agoSuper User
Hi,
Thank you for your feedback.
May I know how your expected result looks like?
- Anonymous4 years agoNot applicable