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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
CarlsBerg999
Helper V
Helper V

Create a DAX relationship

Hi,

 

I have a situation where i have two tables: Category and Products. I want to combine these to a visual. However, this would require a relationship that links Product 1,2,3,4 to "Products" category. I could just create a calculated column for this, but that would be redundant. 

Can i create this relationship with DAX? How?

CarlsBerg999_0-1617890987279.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @CarlsBerg999 ,

 

Based on your description, I create a measure as follows.

test = 

SUMX(FILTER(ALL('Products'),LEFT(MAX('Products'[Products]),3)=LEFT(SELECTEDVALUE('Categories'[Categories]),3)),[Price])

Result:

v-yuaj-msft_0-1618197225166.png

Hope that's what you were looking for.

Best Regards,

Yuna

 

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

4 REPLIES 4
Anonymous
Not applicable

Hi @CarlsBerg999 ,

 

Based on your description, I create a measure as follows.

test = 

SUMX(FILTER(ALL('Products'),LEFT(MAX('Products'[Products]),3)=LEFT(SELECTEDVALUE('Categories'[Categories]),3)),[Price])

Result:

v-yuaj-msft_0-1618197225166.png

Hope that's what you were looking for.

Best Regards,

Yuna

 

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

 

sanalytics
Solution Sage
Solution Sage

 

@CarlsBerg999 

 

The ideal step will be create a Key column then make a relationship by virtual or physical..

 

if you dont want to create any column then  simple Switch or if statement also will help you to acheive this

 

Attached is the .pbis file for your reference

 

https://dropfiles.org/Z5M3DH7C

 

Hope it will help

 

Regards

sanalytics

 

amitchandak
Super User
Super User

@CarlsBerg999 , Created a calculated column is an idea going to work here. Is the service also have data coming from another table?

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Yes, I would like to avoid making calculated columns. Isn't there a way to create this relationship with a measure? 

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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