Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
I have multiple "planned activities" entries in my Dataverse (Project for the Web). On the report i need to indicate the latest entry. How would i do it?
Solved! Go to Solution.
Hi,
I am not sure how your semantic model looks like, but if you want to approach to this in Power Query Editor to create [latest_flag] column, one of ways is to try something like below.
Please check the below picture and the attached pbix file.
let
Source = project_source,
#"Sorted Rows" = Table.Sort(Source,{{"reportingdate", Order.Descending}}),
#"Grouped Rows" = Table.Group(#"Sorted Rows", {"group"}, {{"latestreportdate", each List.Max([reportingdate]), type nullable date}}),
Custom1 = Source,
#"Merged Queries" = Table.NestedJoin(Custom1, {"group"}, #"Grouped Rows", {"group"}, "Custom1", JoinKind.Inner),
#"Expanded Custom1" = Table.ExpandTableColumn(#"Merged Queries", "Custom1", {"latestreportdate"}, {"Custom1.latestreportdate"}),
#"Added Custom" = Table.AddColumn(#"Expanded Custom1", "latest_flag", each if [reportingdate] = [Custom1.latestreportdate] then 1 else 0),
#"Removed Other Columns" = Table.SelectColumns(#"Added Custom",{"group", "plannedactivities", "reportingdate", "latest_flag"})
in
#"Removed Other Columns"
Or, if you want to approach to this problem by creating calcualted column, please check the below picture and the same attached pbix file.
latest_flag CC =
VAR _group = project_source[group]
VAR _reportdate = project_source[reportingdate]
VAR _flagtable =
SELECTCOLUMNS (
FILTER (
ADDCOLUMNS (
project_source,
"@RankByLatest",
RANK (
SKIP,
project_source,
ORDERBY ( project_source[reportingdate], DESC ),
,
PARTITIONBY ( project_source[group] ),
MATCHBY (
project_source[group],
project_source[plannedactivities],
project_source[reportingdate]
)
)
),
[@RankByLatest] = 1
),
"@group", project_source[group],
"@latestdate", project_source[reportingdate]
)
RETURN
COUNTROWS (
FILTER ( _flagtable, [@group] = _group && [@latestdate] = _reportdate )
)
This worked! Thank you!
User | Count |
---|---|
25 | |
12 | |
8 | |
7 | |
7 |
User | Count |
---|---|
27 | |
13 | |
13 | |
10 | |
6 |