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
iamprajot
Responsive Resident
Responsive Resident

Problem with Relationship and Getting Aggregates

Hi

Link to the file is Here.

I have 3 Tables

Orders - Order Related Details with Unique Column, OrderID, OrderDate, ... and so on.

Returns - Contains a single column, ReturnID which contains OrderID that were returned.

Expenses - It contains 2 columns, Expense Date and the Expense Amount.

This Expenses Table is niether related to Orders and nor to Returns as the expenses are of different dates.

 

Now what I want is to create Matrix Table in which I want to show Sold Amount from Orders Table, Returned Amount from Return & Orders Table and Expense for that Month from Expenses Table.

 

In my actual Data I have created relationships in Orders and Returns to get related info.

These tables have no relationship to Expenses Table and I want to create a relationship based on Month and Year so that I could pull the Expenses into the same row in the Matrix Table.

But relationship is not working in my actual Data, so is there a way to get the Expense Amount for the Month into the Table or to recreate some kind of relationship.

NOTE:-Keep that in mind that Relationship in this Data is working but not working in my actual data due to multiple relationships and duplicate OrderID's and ReturnID's so I have inactive the relationships and even if I active them then I am getting blank results.

1 ACCEPTED SOLUTION

Thanks.
It is working in the attached sample data but not working in the actual data.
I somehow need to use the logic provided in the actual scenario or I was thinking of creating a summary table to get the values based on matching conditions.

View solution in original post

2 REPLIES 2
v-shex-msft
Community Support
Community Support

HI @iamprajot,


I think you need to write a formula to manually get available order date range in summary row contents, then find out matched Expenses records.

 

Sample formula:

 

Total Expense = 
VAR _valid =
    MINX ( VALUES ( Orders[OrderDate] ), [OrderDate] )
RETURN
    IF (
        _valid <> BLANK (),
        CALCULATE (
            SUM ( Expenses[Expense] ),
            FILTER (
                ALL ( Expenses ),
                [ExpenseDate]
                    IN CALENDAR (
                        DATE ( YEAR ( _valid ), MONTH ( _valid ), 1 ),
                        DATE ( YEAR ( _valid ), MONTH ( _valid ) + 1, 1 )
                            - 1
                    )
            )
        )
            + 0
    )

12.PNG

 

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Thanks.
It is working in the attached sample data but not working in the actual data.
I somehow need to use the logic provided in the actual scenario or I was thinking of creating a summary table to get the values based on matching conditions.

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.