Cascador84
Cascador84

Reputation: 151

Calculated field in Power BI to repeat value in sublevels

I'm wondering if it was possible to repeat a column value into sublevel record. The link between main dataset (A) et second Dataset (B) is the hierarchy value

I.e

A.Code      A.hierachy      A.level     B.valuetopeat
John        1/              1           Senior
Smith       1/2             2           --> no data by default, need "Senior"
Wesson      1/2/3           3           --> no data by default, need "Senior"
Syl         2/              1           "Junior"
Ves         2/1             2           --> no data by default, need "Junior"
Ter         2/1/1           3           --> no data by default, need "Junior"

Or another approach to get same results could be (always with dataset A & B, but having parent-child columns)

A.Key       A.parentKey     A.Code      B.valuetoRepeat
1                           John        Senior
2           1               Smith       --> no data by default, need "Senior"
3           2               Wesson      --> no data by default, need "Senior"
4                           Syl         "Junior"
5           4               Ves         --> no data by default, need "Junior"
6           5               Ter         --> no data by default, need "Junior"

Thank you

regards,

Upvotes: 0

Views: 125

Answers (1)

davidebacci
davidebacci

Reputation: 30304

You can do this in DAX using PATH functions. It seems like you're trying to flatten a hierarchy which is exactly what they're for.

https://learn.microsoft.com/en-us/dax/parent-and-child-functions-dax

Upvotes: 1

Related Questions