Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowThe Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.
As shown in the attachment, there are three columns: name, parent_name and serial number column ID. Now I want to create a new column parent_id.
The number in the serial number column is automatically displayed based on the relationship between the NAME column and the PARENT_NAME column. For the expected result, see the attachment.
So don't know how the DAX text that creates such a column should be written in PowerBi
name | parent_name | id | parent_id | ||||||
A | H | 1 | 8 | ||||||
B | H | 2 | 8 | ||||||
C | H | 3 | 8 | ||||||
D | G | 4 | 7 | ||||||
E | C | 5 | 3 | ||||||
F | G | 6 | 7 | ||||||
G | E | 7 | 5 | ||||||
H | 8 | ||||||||
Solved! Go to Solution.
Hi, @Shamank77
According to your description, You want to show [parent_id] corresponding to [parent_name] according to the relationship between [name] and [id]. Right?
Here are the steps you can follow :
(1)This is my test data:
(2)We can create a calculated column: “parent_id”:
parent_id =
VAR _table =
SELECTCOLUMNS ( 'Table', "Name", [name], "id", [id] )
RETURN
MAXX ( FILTER ( _table, [name] = EARLIER ( 'Table'[parent_name] ) ), [id] )
(3)Then we can meet your need , the result is as follows:
Best Regards,
Aniya Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Shamank77
You may also try
parent_id =
CALCULATE (
SELECTEDVALUE ( TableName[id] ),
TREATAS ( VALUES ( TableName[parent_name] ), TableName[name] )
)
Hi @tamerj1
Thanks for your suggestion 😊
I tried to make the DAX as :
parent_id = CALCULATE ( SELECTEDVALUE ( TableName[id] ), TREATAS ( VALUES ( TableName[parent_name] ), TableName[name] ) )
but the result became
nameparent_nameidparent_id sampleparent_id
|
Please try
parent_id =
CALCULATE (
SELECTEDVALUE ( TableName[id] ),
TREATAS ( VALUES ( TableName[parent_name] ), TableName[name] ),
REMOVEFILTERS ( TableName )
)
Hi,
Please check the below picture and the attached file.
It is for creating a new column.
Parend_id CC =
LOOKUPVALUE('Table'[id],'Table'[name],'Table'[parent_name])
If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.
Hi, @Shamank77
According to your description, You want to show [parent_id] corresponding to [parent_name] according to the relationship between [name] and [id]. Right?
Here are the steps you can follow :
(1)This is my test data:
(2)We can create a calculated column: “parent_id”:
parent_id =
VAR _table =
SELECTCOLUMNS ( 'Table', "Name", [name], "id", [id] )
RETURN
MAXX ( FILTER ( _table, [name] = EARLIER ( 'Table'[parent_name] ) ), [id] )
(3)Then we can meet your need , the result is as follows:
Best Regards,
Aniya Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi ,Miss Zhang
Thanks for your suggestion~
The result is up to the mustard exactly
Yes,it works!Thank you very much indeed😄
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the February 2025 Power BI update to learn about new features.
User | Count |
---|---|
24 | |
13 | |
11 | |
10 | |
9 |
User | Count |
---|---|
18 | |
14 | |
14 | |
13 | |
12 |