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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
SK87
Helper III
Helper III

Relationship between two datasets through Measures (DAX)

Hi ,

Please help me on below problem:
I have one data set in which brands and respective their respective search values are there. And I have another dataset in which I have done unpivoting and have one column name as Attributes and other as Values. Based on these Attributes values are present and their respective brand is present.
Now, I need to implement a relation between these two datasets as if in 'Data2', Attributes = A then Values should be > 0 and based on this brands should pick in the table.

 

Attributes would be in Slicer (A,B,C and D as dropdown). In Table in Rows as "Brand" variable . But when I select "A" in Slicer then in table I should see only sub categories of A same with B, C and D.

 

BrandSIABCD
B0.8398810100
Bb6.5144070200
Bbb0.039750300
A1.04851000
Aa0.4495272000
Aaa0.364363000
C2.1252010010
Cc2.1686120020
Ccc2.0370370030
Dd8.4764450002
D2.2242670001
Ddddd0.0344270005

 

Dataset2 (unpivot)

BrandSIAttributesValues
B0.839881B1
Bb6.514407B2
Bbb0.03975B3
A1.0485A1
Aa0.449527A2
Aaa0.36436A3
C2.125201C1
Cc2.168612C2
Ccc2.037037C3
Dd8.476445D2
D2.224267D1
Ddddd0.034427D5

Please suggest.

1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @SK87 ,

Here are the steps you can follow:

1. Create calculated table.

Slicer_Date =
DISTINCT('Table2'[Attributes])

vyangliumsft_0-1657677586697.png

2. Create measure.

Flag =
var _select= SELECTEDVALUE('Slicer_Date'[Attributes])
var _mindate=MINX(
    FILTER(ALL('Table2'),'Table2'[Attributes]=_select),
    [Values])
return
SWITCH(
    TRUE(),
    MAX('Table2'[Attributes])=_select&&MAX('Table2'[Values])>_mindate,1,
    MAX('Table2'[Attributes])<>_select&&MAX('Table2'[Values])>_mindate,1,0
    )

3. Place [Flag]in Filters, set is=1, apply filter.

vyangliumsft_1-1657677586698.png

4. Result:

vyangliumsft_2-1657677586699.png

If you need pbix, please click here.

If I have misunderstood your meaning, please provide your desired output and pbix without privacy information.

Best Regards,

Liu Yang

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
v-yangliu-msft
Community Support
Community Support

Hi  @SK87 ,

Here are the steps you can follow:

1. Create calculated table.

Slicer_Date =
DISTINCT('Table2'[Attributes])

vyangliumsft_0-1657677586697.png

2. Create measure.

Flag =
var _select= SELECTEDVALUE('Slicer_Date'[Attributes])
var _mindate=MINX(
    FILTER(ALL('Table2'),'Table2'[Attributes]=_select),
    [Values])
return
SWITCH(
    TRUE(),
    MAX('Table2'[Attributes])=_select&&MAX('Table2'[Values])>_mindate,1,
    MAX('Table2'[Attributes])<>_select&&MAX('Table2'[Values])>_mindate,1,0
    )

3. Place [Flag]in Filters, set is=1, apply filter.

vyangliumsft_1-1657677586698.png

4. Result:

vyangliumsft_2-1657677586699.png

If you need pbix, please click here.

If I have misunderstood your meaning, please provide your desired output and pbix without privacy information.

Best Regards,

Liu Yang

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

SpartaBI
Community Champion
Community Champion

@SK87 I don't think you need a relationship. Everything you need is already in the unpivot dataset. I just added a brand category group there. Check out this sample file: Relationship between two datasets through Measures (DAX) 2022-07-10.pbix


2022-05-19 17_30_22-Re_ Need help on DAX function with measure vs colu... - Microsoft Power BI Commu.png


Full-Logo11.png

SpartaBI_3-1652115470761.png   SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Showcase Report – Contoso By SpartaBI

@SpartaBI 

 

Thanks for your response.

 

I had shared an example table, brand names are not synchronised. I can't use left function for brand category.

brand names are of shoes like Nike, Adidas, Converse etc.So this solution is not correct for my dataset. 

Kindly suggest something else if possible.

SpartaBI
Community Champion
Community Champion

@SK87 can you sharea sample of your real data and also the desired graph result. If not, PM me

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

Top Solution Authors