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

Try your skills in the Power BI Dataviz World Championship! Round one ends June 26. Join now

Reply
Anonymous
Not applicable

Grouping Values by Ranges Retreived from a Different Table under Two Conditions

Dear Community,

 

I have the following two tables in my data model:

Compare and Retreive.jpg

Using a DAX-Expression, the column "Headcount Range" in the "Company List" table shall be filled with the "Range" value from the "Headcount Ranges" table, by applying the condtion that "Headcount" is greater or equal to "Lower Threshold" AND smaller or equal to "Upper Threshold".

 

Besides RELATED(), I have been experimenting with the LOOKUPVALUE() function, but there does not seem to be a way to formaulate the condition in the third argument, is there?.

Could sombedoy help me out with a solution, please?

 

Best regards,

Wolfi

1 ACCEPTED SOLUTION

Thank you for the file. See if this works for you.

A. As a calculated column

Headcount Range =
VAR _Threshold =
    CALCULATE (
        MIN ( 'Headcount Ranges'[Upper Threshold] ),
        FILTER (
            'Headcount Ranges',
            'Headcount Ranges'[Upper Threshold] >= 'Company List'[Headcount]
        )
    ) // Calculates the minimum upper threshold value in the Headcount table which is greater or equal to the Company list[Headcount]
RETURN
    LOOKUPVALUE (
        'Headcount Ranges'[Range],
        'Headcount Ranges'[Upper Threshold], _Threshold
    )
// Retruns the range value on the Headcount Ranges table where the upper threshold is the same as the calculated _Threshold value 

result.jpg

B. As a measure

Headcount Range (measure) =
VAR _Threshold =
    CALCULATE (
        MIN ( 'Headcount Ranges'[Upper Threshold] ),
        FILTER (
            'Headcount Ranges',
            'Headcount Ranges'[Upper Threshold] >= SUM ( 'Company List'[Headcount] )
        )
    )
RETURN
    LOOKUPVALUE (
        'Headcount Ranges'[Range],
        'Headcount Ranges'[Upper Threshold], _Threshold
    )

measure.jpg

Sample PBIX file attached





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Many thanks, Paul, for a job very well done! Your solution works just as it is supposed to!

PaulDBrown
Community Champion
Community Champion

It would help if you shared some sample dummy data or a link to a dummy PBIX file





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Anonymous
Not applicable

Hi Paul, 

 

thanks for your quick reply. Please find the dummy file under this link.

 

Best,

Wolfi

Thank you for the file. See if this works for you.

A. As a calculated column

Headcount Range =
VAR _Threshold =
    CALCULATE (
        MIN ( 'Headcount Ranges'[Upper Threshold] ),
        FILTER (
            'Headcount Ranges',
            'Headcount Ranges'[Upper Threshold] >= 'Company List'[Headcount]
        )
    ) // Calculates the minimum upper threshold value in the Headcount table which is greater or equal to the Company list[Headcount]
RETURN
    LOOKUPVALUE (
        'Headcount Ranges'[Range],
        'Headcount Ranges'[Upper Threshold], _Threshold
    )
// Retruns the range value on the Headcount Ranges table where the upper threshold is the same as the calculated _Threshold value 

result.jpg

B. As a measure

Headcount Range (measure) =
VAR _Threshold =
    CALCULATE (
        MIN ( 'Headcount Ranges'[Upper Threshold] ),
        FILTER (
            'Headcount Ranges',
            'Headcount Ranges'[Upper Threshold] >= SUM ( 'Company List'[Headcount] )
        )
    )
RETURN
    LOOKUPVALUE (
        'Headcount Ranges'[Range],
        'Headcount Ranges'[Upper Threshold], _Threshold
    )

measure.jpg

Sample PBIX file attached





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.