Please help in wrting a dax measure . TPID has multiple managers (MWA) and I need to repeat the first manager for the same tpid. as shown below
TPID MWA Desired Values
1 | Jame | Jame |
1 | Billy | Jame |
1 | Camy | Jame |
1 | Billy | Jame |
2 | Billy | |
2 | Billy | Billy |
2 | Camy | Billy |
2 | Billy | |
3 | Ammar | Ammar |
3 | Ammar | Ammar |
3 | Ammar | |
3 | Camy | Ammar |
Solved! Go to Solution.
Hello @ahmedaldafaae ,
According to my understanding, you want to use the first non-blank value in each id group as the value of the same group, right?
You can use the following formula after adding an index column:
Measure =
VAR _firstnoblank =
CALCULATE (
MIN ( 'Table'[Index] ),
FILTER (
ALL ( 'Table' ),
'Table'[TPID] = MAX ( 'Table'[TPID] )
&& 'Table'[MWA] <> BLANK ()
)
)
RETURN
CALCULATE (
MAX ( 'Table'[MWA] ),
FILTER ( ALL ( 'Table' ), 'Table'[Index] = _firstnoblank )
)
My visualization looks like this:
Have I answered your question? Please mark my answer as a solution. Thanks a lot.
If not, load some samples of insensitive data and expected output.
Best regards
Eyelyn Qin
Hello @ahmedaldafaae ,
According to my understanding, you want to use the first non-blank value in each id group as the value of the same group, right?
You can use the following formula after adding an index column:
Measure =
VAR _firstnoblank =
CALCULATE (
MIN ( 'Table'[Index] ),
FILTER (
ALL ( 'Table' ),
'Table'[TPID] = MAX ( 'Table'[TPID] )
&& 'Table'[MWA] <> BLANK ()
)
)
RETURN
CALCULATE (
MAX ( 'Table'[MWA] ),
FILTER ( ALL ( 'Table' ), 'Table'[Index] = _firstnoblank )
)
My visualization looks like this:
Have I answered your question? Please mark my answer as a solution. Thanks a lot.
If not, load some samples of insensitive data and expected output.
Best regards
Eyelyn Qin
Thank you
It simply works!!
@ahmedaldafaae
I tried a Power Query solution adding just one custom column:
Paste the below code in a blank Query in the Advanced Editor and check the step added.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUfJKzE1VitWBcJwyc3Iq4TznxNxKLFJGQJ4CnIUqDteCUGQMZDnm5iYW4eAhVEE0xwIA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [TPID = _t, MWA = _t]),
#"Added Custom" = Table.AddColumn(Source, "New MWA", (r)=> List.First(Table.SelectRows(Source, each [TPID] = r[TPID] and [MWA] <> " ")[MWA]))
in
#"Added Custom"
________________________
If my answer was helpful, please consider Accept it as the solution to help the other members find it
Click on the Thumbs-Up icon if you like this reply 🙂
______________
Check out my Data Stories Gallery Christmas Report: Are you on Santa's Naughty or Nice List?
______________
Has this post solved your problem? Please mark it as a solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos.
I work as a trainer and consultant for Microsoft 365, specialising in Power BI and Power Query.
User | Count |
---|---|
334 | |
135 | |
83 | |
75 | |
45 |
User | Count |
---|---|
379 | |
225 | |
117 | |
107 | |
101 |