Forum Discussion
SEwing
3 months agoFrequent Visitor
How to use latest date from multiple rows for visualization
I'm trying to create visual for Site Job Completions by month. The data looks like this: Site Job Number Job Completion Date Measure of Completed Sites Dates Count of Sites/Month Alp...
- 3 months ago
you can create a new table and use the new table to display the result
SummaryTable =VAR BaseTable =ADDCOLUMNS (SUMMARIZE ( 'Jobs', 'Jobs'[Site] ),"Max Job Completion Date",VAR HasBlankDate =CALCULATE (COUNTROWS ( 'Jobs' ),KEEPFILTERS ( 'Jobs'[Job Completion Date] = BLANK () ))VAR MaxNonBlankDate =CALCULATE (MAX ( 'Jobs'[Job Completion Date] ),'Jobs'[Job Completion Date] <> BLANK ())RETURNIF (HasBlankDate > 0,BLANK (), -- Max Job Completion Date (Delta = blank)MaxNonBlankDate))RETURNADDCOLUMNS (BaseTable,"Month",VAR MaxNonBlankDateForSite =CALCULATE (MAX ( 'Jobs'[Job Completion Date] ),'Jobs'[Job Completion Date] <> BLANK ())RETURNIF (ISBLANK ( MaxNonBlankDateForSite ),BLANK (),FORMAT ( MaxNonBlankDateForSite, "MMM" ) -- or "MMMM"))pls see the attachment below
ryan_mayu
3 months agoSuper User
you can create a new table and use the new table to display the result
SummaryTable =
VAR BaseTable =
ADDCOLUMNS (
SUMMARIZE ( 'Jobs', 'Jobs'[Site] ),
"Max Job Completion Date",
VAR HasBlankDate =
CALCULATE (
COUNTROWS ( 'Jobs' ),
KEEPFILTERS ( 'Jobs'[Job Completion Date] = BLANK () )
)
VAR MaxNonBlankDate =
CALCULATE (
MAX ( 'Jobs'[Job Completion Date] ),
'Jobs'[Job Completion Date] <> BLANK ()
)
RETURN
IF (
HasBlankDate > 0,
BLANK (), -- Max Job Completion Date (Delta = blank)
MaxNonBlankDate
)
)
RETURN
ADDCOLUMNS (
BaseTable,
"Month",
VAR MaxNonBlankDateForSite =
CALCULATE (
MAX ( 'Jobs'[Job Completion Date] ),
'Jobs'[Job Completion Date] <> BLANK ()
)
RETURN
IF (
ISBLANK ( MaxNonBlankDateForSite ),
BLANK (),
FORMAT ( MaxNonBlankDateForSite, "MMM" ) -- or "MMMM"
)
)
pls see the attachment below