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
Balázs_Fenyő
Frequent Visitor

Connencting 2 rows to one row in another table

I have a huge table with data like this:

dateorder_idslot_idviews
2020-11-121110
2020-11-121210
2020-11-122110

And so on.

 

I have another table where I have sales values for this data like this:

sale_idvalue
110
212
315

 

And the I have another table that connects these 2 tables, but I have rows where I have two (or more) sale_ids to one order_id, and rows where there is no sale_id because it is not associated to this table. Like this:

order_idsale_id1sale_id2sale_id3sum_value
123null 
21nullnull 
3nullnullnull 

 

I would like to see the sum_value of the order in some way and, this is probably a second problem, also know the value of 1 view, which in this case is the (sum_value / sum_views).

 

Looked all around this forum but just couldn't get my head around it. Any help is appreciated.

1 ACCEPTED SOLUTION
Icey
Community Support
Community Support

Hi @Balázs_Fenyő ,

 

Please check if this is what you want:

 

1. UnPivot.

UNPIVOT.gif

 

2. Create relationships.

relationship.JPG

 

3. Create calculated columns or measures.

Columns:

sum_value =
CALCULATE (
    SUM ( Sales[value] ),
    ALLEXCEPT ( ConnectTable, ConnectTable[order_id] )
)
sum_views =
CALCULATE (
    SUM ( Views[views] ),
    ALLEXCEPT ( ConnectTable, ConnectTable[order_id] )
)
sum_value / sum_views = DIVIDE( [sum_value], [sum_views])

columns.JPG

 

Measure:

sum_value / sum_view = 
VAR sum_value =
    CALCULATE (
        SUM ( Sales[value] ),
        ALLEXCEPT ( ConnectTable, ConnectTable[order_id] )
    )
VAR sum_view =
    CALCULATE (
        SUM ( Views[views] ),
        ALLEXCEPT ( ConnectTable, ConnectTable[order_id] )
    )
RETURN
    DIVIDE ( sum_value, sum_view )

measure.JPG

 

 

 

 

Best regards

Icey

 

If this post helps, then consider Accepting it as the solution to help other members find it faster.

View solution in original post

3 REPLIES 3
Icey
Community Support
Community Support

Hi @Balázs_Fenyő ,

 

Please check if this is what you want:

 

1. UnPivot.

UNPIVOT.gif

 

2. Create relationships.

relationship.JPG

 

3. Create calculated columns or measures.

Columns:

sum_value =
CALCULATE (
    SUM ( Sales[value] ),
    ALLEXCEPT ( ConnectTable, ConnectTable[order_id] )
)
sum_views =
CALCULATE (
    SUM ( Views[views] ),
    ALLEXCEPT ( ConnectTable, ConnectTable[order_id] )
)
sum_value / sum_views = DIVIDE( [sum_value], [sum_views])

columns.JPG

 

Measure:

sum_value / sum_view = 
VAR sum_value =
    CALCULATE (
        SUM ( Sales[value] ),
        ALLEXCEPT ( ConnectTable, ConnectTable[order_id] )
    )
VAR sum_view =
    CALCULATE (
        SUM ( Views[views] ),
        ALLEXCEPT ( ConnectTable, ConnectTable[order_id] )
    )
RETURN
    DIVIDE ( sum_value, sum_view )

measure.JPG

 

 

 

 

Best regards

Icey

 

If this post helps, then consider Accepting it as the solution to help other members find it faster.

amitchandak
Super User
Super User

@Balázs_Fenyő , not very clear. You can unpivot the third table and join it with one and two

Yes, but then order_id won't be unique in this table

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.