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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
CRN
Helper I
Helper I

Max value based on category and ID

Hi all,

 

I'm looking for the ID of a higher level in the hiearichy.

 

The level hierarchy is:

1

2

3

 

E.g a Level 3 with ID 5 should fint the highest ID for the Level 2 total and still lower than it's own ID.

 

This is an example of the wanted structure:

CRN_1-1663672956930.png

 

 

Thanks!

 

1 ACCEPTED SOLUTION
Jos_Woolley
Solution Sage
Solution Sage

Hi,

This measure:

 

ID of Parent =
VAR ThisLevel =
    MIN( 'Table'[Level] )
VAR ThisID =
    MIN( 'Table'[ID] )
VAR ParentID =
    CALCULATE(
        MAX( 'Table'[Description] ),
        FILTER(
            ALL( 'Table' ),
            'Table'[Level] = ThisLevel - 1
                && 'Table'[ID] < ThisID
        )
    )
RETURN
    ParentID

 

In the Visualizations panel, click the dropdown next to 'ID' and check 'Show Items with no data' if you want the result for the first ID to be included.

Regards

View solution in original post

3 REPLIES 3
CRN
Helper I
Helper I

Is there any way to create is as a column instead of a measure?

 

Thanks.

Jos_Woolley
Solution Sage
Solution Sage

Hi,

This measure:

 

ID of Parent =
VAR ThisLevel =
    MIN( 'Table'[Level] )
VAR ThisID =
    MIN( 'Table'[ID] )
VAR ParentID =
    CALCULATE(
        MAX( 'Table'[Description] ),
        FILTER(
            ALL( 'Table' ),
            'Table'[Level] = ThisLevel - 1
                && 'Table'[ID] < ThisID
        )
    )
RETURN
    ParentID

 

In the Visualizations panel, click the dropdown next to 'ID' and check 'Show Items with no data' if you want the result for the first ID to be included.

Regards

Hi @Jos_Woolley ,

 

Thanks for your suggestion! It worked just like I wanted it.

 

My appologies for the late response. I got caught on other issues.

 

Thanks again!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors