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
emilypoon
Advocate I
Advocate I

DAX - How to work out USERELATIONSHIP and Aggregate function (first) together

Hi,

 

I have a dataset with the following columns.

- PolCountryName = display the country name from my dataset

- First PolCountryName = display the "first" PolCountryName using the aggregated function

- Year1 = display the "ShipmentItemManifested" column in year

- Year2 = display the "MasterDate" column in year

- Year3 = display the "LandsideBookingReceiptDate" column in year

- Percentage = display the DAX calculation using the below formula:

 
Percentage =
CALCULATE(AVERAGE(OrderedItemSummaryBI[Table_UtilizedRatePerContainer]),
USERELATIONSHIP(OrderedItemSummaryBI[DateOnly_ShipmentItemManifested],MasterCalendar[MasterDate]))

 

image.png

image.png

 

As per above setup, I want to activate the relationship between ShipmentItemManifested & MasterDate.

According to my model, the current active relationship is between LandsideBookingReceiptDate & MasterDate, but not between ShipmentItemManifested & MasterDate.

When I calculate the Percentage, I want to activate the relationship between ShipmentItemManifested & MasterDate and that's why I calculated using the above formula. The calculation is correct and successful but the problem is that the "First PolCountryName" column becomes blank if I have a value in the "Percentage" column.

 

How can I ensure the "First PolCountryName" column is not blank given that I must have USERELATIONSHIP in my model? In addition, I must stick with the "First PolCountryName" column for some reason and I can't just simply use "PolCountryName".

 

If I simply calculate the Percentage without using USERELATIONSHIP, the "First PolCountryName" column displays correctly (See below demo example).

image.png

 

Is there anyone can help the above problem?

Thanks!

 

Best regards,

Emily

 

 

2 REPLIES 2
v-yulgu-msft
Employee
Employee

Hi @emilypoon ,

 

If you activate the relationship between ShipmentItemManifested & MasterDate via using USERELATIONSHIP, it would make the current active relationship to be inactive, which might cause the blank value of First PolCountryNam column.

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-yulgu-msft 

In my case, I must activate the relationship between ShipmentItemManifested & MasterDate via using USERELATIONSHIP but same time I want the Percentage to be displayed properly without showing blank in the table.

What I don't understand is why the table shows blank in the FirstPolCountry even if I activate ShipmentItemManifested & MasterDate.

Any solutions to solve this problem? Thanks!

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.