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
Maryna
Regular Visitor

DAX formula which returns the text value that related to the range from another table

Hi Community. 
I am looking to DAX formula that returns the text value that related to the range from another table.
 
I have 1st table with wll company accounts in it, 2nd table with accounts ranges (Start account, End account) and related indicator to the range. I need to bring indicator name from 2nd table to the 1st table. 
 
This if formula does not work for account numbers "in between" the range or simply if account # from the 1st table does not match to the Start Account # from the 2nd table.

 

You can load pbix test file

https://drive.google.com/drive/folders/1UmYcl7frXv347k1nOs4lVxvvW2QeaHxOCapture3.jpgCapture1.JPGCapture2.jpg

Thank you.

1 ACCEPTED SOLUTION
JarroVGIT
Resident Rockstar
Resident Rockstar

First off, thanks for including the PBIX file, that really helped as I couldn't fully understand what you were trying to achieve by your question! 🙂

You don't need a relationship between the tables. I hope I understood your question correctly. My understanding is that you want to have a calculated column in table "Account" which reflects which indicator belongs to the account number. Indicators are given in the "Indicator" column with a start value and end value, and when an account number in the "account" table is equal to start or end or is in between that value, you want that corresponding Indicator to the account table.

This is the dax that does just that:

Indicator = CALCULATE(SELECTEDVALUE(Indicator[Indicator]), FILTER(ALL(Indicator), Indicator[StartAccount] <= Account[Account] && Indicator[EndAccount] >= Account[Account]))

 

Kind regards

Djerro123

-------------------------------

If this answered your question, please mark it as the Solution. This also helps others to find what they are looking for.

Keep those thumbs up coming! 🙂





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

2 REPLIES 2
JarroVGIT
Resident Rockstar
Resident Rockstar

First off, thanks for including the PBIX file, that really helped as I couldn't fully understand what you were trying to achieve by your question! 🙂

You don't need a relationship between the tables. I hope I understood your question correctly. My understanding is that you want to have a calculated column in table "Account" which reflects which indicator belongs to the account number. Indicators are given in the "Indicator" column with a start value and end value, and when an account number in the "account" table is equal to start or end or is in between that value, you want that corresponding Indicator to the account table.

This is the dax that does just that:

Indicator = CALCULATE(SELECTEDVALUE(Indicator[Indicator]), FILTER(ALL(Indicator), Indicator[StartAccount] <= Account[Account] && Indicator[EndAccount] >= Account[Account]))

 

Kind regards

Djerro123

-------------------------------

If this answered your question, please mark it as the Solution. This also helps others to find what they are looking for.

Keep those thumbs up coming! 🙂





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




The formula works perfectly!

Thank you @JarroVGIT 

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.