Forum Discussion
Progress column in table dependent on other table
Hi, I have a report with 4 tables representing a hierarchy in ADO.
For each level, I wish to create a progress column which if the item has children, use the average of the children's progress, and if there are no children, simply map the ADO state to a static table i have made with pairs of Status, Score (number between 0 and 1 to indicate percentage).
So for a feature, I would like to check if there are any children. If theres is, take the average of the stories' progress columns and assign that. If there are none, find a match from the StateMapping table, and assign the corresponding progress to that state.
I have been able to do this with both nesting the table of stories, and with fetching matching rows with the Table.SelectRows. However, they both make the performance of my model deteriorate harsly. Am I doing this in a very little computationally efficient manner? If so, how could I do so more efficiently?
In advance, thank you for any help or response. Appending two different formula used for creating new column:
= Table.AddColumn(#"Previous", "Progress", each let
currentStatus = [State],
matchingRow = Table.SelectRows(
StateMapping,
each [State] = currentStatus
)
in
if Table.RowCount(matchingRow) > 0 and Table.RowCount([Stories]) = 0 then matchingRow{0}[Score]
else if Table.RowCount([Stories]) > 0 then List.Average([Stories][Progress])
else 0
)
= Table.AddColumn(#"Previous Step", "Progress", each let
currentStatus = [State],
WID = [Work Item Id],
matchingChildren = Table.SelectRows(
Tasks,
each [Parent Work Item Id] = WID
),
matchingRow = Table.SelectRows(
StateMapping,
each [State] = currentStatus
)
in
if Table.RowCount(matchingChildren) = 0 and Table.RowCount(matchingRow) > 0 then matchingRow{0}[Score]
else if Table.RowCount(matchingChildren) > 0 then List.Average(matchingChildren[Progress])
else 0)- Anonymous2 years ago
I had tried both versions in all levels (I tried doing all levels with merges as well as selectrows), however, the performance deteriorated even with the merges. What ended up solving the problem for me was to instead use a calculated column in DAX instead of Power Query. This would be a major issue had I been importing to Excel, but for Power BI this works with good performance:
Progress = VAR SelectedEpicID = Epics[ID] VAR RelatedFeatures = FILTER(Features, Features[ParentID] = SelectedEpicID) RETURN IF( COUNTROWS(RelatedFeatures) > 0, SUMX(RelatedFeatures, Features[Progress] * Features[Effort]) / SUMX(RelatedFeatures, Features[Effort]), LOOKUPVALUE( StatusMapping[Score], StatusMapping[Status], Epics[State] ) )
2 Replies
- AnonymousNot applicable
Hi Anonymous
Use Merge queries feature more to find the matching results from the other table based on one or more matching columns, this can usually have a better performance than using Table.SelectRows to find the same results. The other statements currently do not seem to have much impact on performance.
Hope this would be helpful!
Best Regards,
Jing
If this post helps, please Accept it as Solution to help other members find it. Appreciate your Kudos!- AnonymousNot applicable
I had tried both versions in all levels (I tried doing all levels with merges as well as selectrows), however, the performance deteriorated even with the merges. What ended up solving the problem for me was to instead use a calculated column in DAX instead of Power Query. This would be a major issue had I been importing to Excel, but for Power BI this works with good performance:
Progress = VAR SelectedEpicID = Epics[ID] VAR RelatedFeatures = FILTER(Features, Features[ParentID] = SelectedEpicID) RETURN IF( COUNTROWS(RelatedFeatures) > 0, SUMX(RelatedFeatures, Features[Progress] * Features[Effort]) / SUMX(RelatedFeatures, Features[Effort]), LOOKUPVALUE( StatusMapping[Score], StatusMapping[Status], Epics[State] ) )