Supplies are limited. Contact info@espc.tech right away to save your spot before the conference sells out.
Get your discountScore big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount
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])
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😄
User | Count |
---|---|
13 | |
12 | |
8 | |
8 | |
6 |
User | Count |
---|---|
28 | |
19 | |
13 | |
11 | |
7 |