Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

DAX expression needed to create calculated column where vLookup kind of functionality is needed

Need help in classifying data in a Calculated Column using DAX.

Below is How my data looks:

DAX.PNG

 

        

 

 

 

 

 

 

 

 

 

 

Unique Data - This data is unique and only one of it will be available in the dataset

Parent Data - These are parent data. They may have multiple Unique data under them as their child as they are related. Also if the column is NULL then the correcponding Unique data is a Parent by itself since its not having data under it.

 

Calculated column Output - Here i need to use DAX to classify the 'Unique Data' as Parent or Child.

Rules for the classification -

1. If 'Unique Data' column has NULL value in 'Parent Data', then its a Parent

2. If 'Unique Data' column is available in 'Parent Data' as some other data' parent, then its a Parent.

3. If 'Unique Data' column is not available in 'Parent Data', then its a Child

 

All the above rules will get the all the Unique data Sorted into 2 categories and since they need to refer the Parent data like a vlookup i need help, since it will take time to do calculation in actual data set i need it optimised as well. If a Unique data has a correspoding NULL in Parent data then it does not need to be checked like a vlookup, and Unqiue data which has a Parent data needs to be compared to the non-NULL values in Parent data to be categorised.

1 ACCEPTED SOLUTION
v-robertq-msft
Community Support
Community Support

Hi, @Anonymous 

According to your description and sample data, I can clearly understand your requirement, I think you can try to create a calculated column like this to achieve your requirement:

Output =
var _parentdate=SELECTCOLUMNS(FILTER('Table',NOT(ISBLANK([Parent Data]))),"1",[Parent Data])
return
SWITCH(
    TRUE(),
    ISBLANK([Parent Data]),"Parent",
    [Unique Data] in _parentdate,"Parent",
    NOT([Unique Data] in _parentdate),"Child",
    BLANK())

And you can get what you want, like this:

v-robertq-msft_0-1621848079842.png

 

You can download my test pbix file below

 

If this you still have a problem, you can post some sample data(without sensitive data) and your expected result.

How to Get Your Question Answered Quickly 

Thank you very much!

 

Best Regards,

Community Support Team _Robert Qin

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-robertq-msft
Community Support
Community Support

Hi, @Anonymous 

According to your description and sample data, I can clearly understand your requirement, I think you can try to create a calculated column like this to achieve your requirement:

Output =
var _parentdate=SELECTCOLUMNS(FILTER('Table',NOT(ISBLANK([Parent Data]))),"1",[Parent Data])
return
SWITCH(
    TRUE(),
    ISBLANK([Parent Data]),"Parent",
    [Unique Data] in _parentdate,"Parent",
    NOT([Unique Data] in _parentdate),"Child",
    BLANK())

And you can get what you want, like this:

v-robertq-msft_0-1621848079842.png

 

You can download my test pbix file below

 

If this you still have a problem, you can post some sample data(without sensitive data) and your expected result.

How to Get Your Question Answered Quickly 

Thank you very much!

 

Best Regards,

Community Support Team _Robert Qin

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Greg_Deckler
Community Champion
Community Champion

@Anonymous Perhaps something like:

Column = 
  SWITCH(TRUE(),
    [Parent Data] = "NULL","Parent",
    [Unique Data] IN SELECTCOLUMNS(FILTER('Table',[Parent Data]="NULL"),"Parent",[Unique Data]),"Parent",
    "Child"
  )


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.