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

Many to one relationship duplicate value

I have this data:

DateMasterCategorySubCategoryAmount
8-August-2022FoodGrocery200
8-August-2022FoodGrocery31
8-August-2022FoodRestaurant40
8-August-2022ShoppingElectronics30
9-August-2022FoodGrocery10
10-August-2022ShoppingElectronics5
11-August-2022FoodRestaurant10
12-August-2022ShoppingGrocery10

 

My goal is to generate

DateMasterCategorySubCategoryTotal Amount
2022-08-08 00:00:00FoodGrocery231
2022-08-08 00:00:00FoodRestaurant40
2022-08-08 00:00:00ShoppingElectronics30
2022-08-08 00:00:00ShoppingGrocery0
2022-08-09 00:00:00FoodGrocery10
2022-08-09 00:00:00FoodRestaurant0
2022-08-09 00:00:00ShoppingElectronics0
2022-08-09 00:00:00ShoppingGrocery0
2022-08-10 00:00:00FoodGrocery0
2022-08-10 00:00:00FoodRestaurant0
2022-08-10 00:00:00ShoppingElectronics5
2022-08-10 00:00:00ShoppingGrocery0
2022-08-11 00:00:00FoodGrocery0
2022-08-11 00:00:00FoodRestaurant10
2022-08-11 00:00:00ShoppingElectronics0
2022-08-11 00:00:00ShoppingGrocery0
2022-08-12 00:00:00FoodGrocery0
2022-08-12 00:00:00FoodRestaurant0
2022-08-12 00:00:00ShoppingElectronics0
2022-08-12 00:00:00ShoppingGrocery10

 

I have almost hit the goal but now I am running into this error within my linked solution:

farooqk_0-1686863637574.png

 


 Most likely being caused by last line of the data.

 

I hope someone can provide a solution here.

1 ACCEPTED SOLUTION
VahidDM
Super User
Super User

Hi @farooqk 

Please remove the relationship first, then use this DAX expression to create a new table:

New Table = 
VAR _Date =
    VALUES ( Data[Date] )
VAR _Cat =
    SUMMARIZE ( Data, Data[MasterCategory], Data[SubCategory] )
RETURN
    ADDCOLUMNS (
        CROSSJOIN ( _Date, _Cat ),
        "Amount", CALCULATE ( SUM ( Data[Amount] ), KEEPFILTERS ( Data[Date] ) ) + 0
    )

 

The output:

VahidDM_0-1686875294828.png

 

 

 

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

Appreciate your Kudos!! 

Badges.jpg

LinkedIn | Twitter | Blog | YouTube 

View solution in original post

2 REPLIES 2
VahidDM
Super User
Super User

Hi @farooqk 

Please remove the relationship first, then use this DAX expression to create a new table:

New Table = 
VAR _Date =
    VALUES ( Data[Date] )
VAR _Cat =
    SUMMARIZE ( Data, Data[MasterCategory], Data[SubCategory] )
RETURN
    ADDCOLUMNS (
        CROSSJOIN ( _Date, _Cat ),
        "Amount", CALCULATE ( SUM ( Data[Amount] ), KEEPFILTERS ( Data[Date] ) ) + 0
    )

 

The output:

VahidDM_0-1686875294828.png

 

 

 

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

Appreciate your Kudos!! 

Badges.jpg

LinkedIn | Twitter | Blog | YouTube 

Thanks for the help!

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.