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
slothman
Microsoft Employee
Microsoft Employee

Custom column or measure

Hello all,

 

I need help with a custom column or maybe a measure with the following logic:

Basically I have a table with categories and some values around them (Date column) where not all rows have data for that value column. You can think of category column as a hierarchy. What I want to achieve is to remove the rows that do not have any data but keep the parent nodes associated with the rows that have data. 

 

The logic for OutcomeWanted (OW) column/measure:

  • Check if Date column has a value, if it does then OW value is 1;
  • If OW = 1 assign 1 for it's immediate parents:
    • On row 3 below since the data appears on depth 2 its parent would be depth = 1 with MAX(SortOrder) since there could be other step-parent categories in that level with or without their own children. 
    • Once the parent is assigned iterate up and find parent's parent and evaluate to 1.
    • To better illustrate the logic, consider row with Child_2_3_2_1. 
      • It has data thus would evaluate to 1.
      • Since it is on depth 4 its parent would be with depth 3.
      • Since there are multiple categories with depth 3, the one with closest SortOrder should be assigned as its parent. So Child_2_3_2_1 has a SortOrder of 12, thus its parent must be row with Depth = 3 and Max(SortOrder) < CurrentChild(SortOrder), which is Child_2_3_2
      • Once Child_2_3_2 value is found its parent must be found with the same logic and assigned a value of 1. In this case it would be - Child_2_3.
      • So on and so forth untill the Parent category. 
  • If Date column is empty then assign 0.
CategoryDateSortOrderDepthOutcomeWanted
Parent 101
Child_1 211
Child_1_11/1/2020321
Child_1_2 420
Child_1_2_1 530
Child_2 611
Child_2_1 720
Child_2_2 820
Child_2_3 921
Child_2_3_1 1030
Child_2_3_2 1131
Child_2_3_2_12/2/20201241
Child_3 1310

 

The idea is to filter out based on OW column by showing only values with 1. So my final table would look like this:

CategoryDateSortOrderDepthOutcomeWanted
Parent 101
Child_1 211
Child_1_11/1/2020321
Child_2 611
Child_2_3 921
Child_2_3_2 1131
Child_2_3_2_12/2/20201241

 

Thanks for looking.

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I am not sure if the below solution is the best way to approach, but please check the below picture and the attached pbix file. I tried to use PATH function and PATHITEM function to create the Outcome Wanted Calculated Column.

 

Picture1.png


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.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi,

I am not sure if the below solution is the best way to approach, but please check the below picture and the attached pbix file. I tried to use PATH function and PATHITEM function to create the Outcome Wanted Calculated Column.

 

Picture1.png


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.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Thank you very much, this works great!

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.