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
kasiaw29
Resolver II
Resolver II

Sum value from inactive relationship minus value from active relationship

Hope this makes sense! 

 

I have a date dim and a table- lets call it sales. 

Sales table has an active relationship on sales date and an inactive relationship on refund date. 

I have a sum of sales and I also have a sum of refunds ( by using USERELATIONSHIP ). If I drop them on a chart where my axis is just date from date dim I get a perfect view of the value of sales and refunds (all refunds are negative values) by month. 

 

I've been asked to take away refunds from sales values to get a true sales value figure. 

Is this even possible? I did try taking simply one away from another but it did not work as expected. 

 

Examples: 

 

True Sales = [Sales Value] - [Refunded Values] 

 

Refund Values measure=
CALCULATE(
    SUM('Sales'[Total Gbp]),
    'Sales'[Transaction Code] =  "REFUND" ,
USERELATIONSHIP(DateDim[Date],'Sales'[Refunded Date]))

 

Thanks,

Kasia 

1 ACCEPTED SOLUTION

Hey @amitchandak  thanks for your solution. I looked at it with fresh pair of eyes today. I was making THE most silly mistake ever of doing this True Sales = [Sales Value] - [Refunded Values]  where it should have been True Sales = [Sales Value] + [Refunded Values] 

 

As refund values were negative so -1500, -500, -5478 I needed them added to sales value so that it would actually take them away. 

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@kasiaw29 , Try like

 

CALCULATE(
SUM('Sales'[Total Gbp]),
filter('Sales','Sales'[Transaction Code] = "REFUND" && not(isblank('Sales'[Refunded Date]))),
USERELATIONSHIP(DateDim[Date],'Sales'[Refunded Date]))

 

or

Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Hey @amitchandak  thanks for your solution. I looked at it with fresh pair of eyes today. I was making THE most silly mistake ever of doing this True Sales = [Sales Value] - [Refunded Values]  where it should have been True Sales = [Sales Value] + [Refunded Values] 

 

As refund values were negative so -1500, -500, -5478 I needed them added to sales value so that it would actually take them away. 

Hi @kasiaw29 ,

 

Sorry I'm a little confused about your request,is your issue solved now?If not,could you pls share some sample data with expected output for test?

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

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.