Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
miss-ness
Regular Visitor

How to subtract one measure from another with different filters for each

Hello PBI wizards! Is anyone able to help me logic out this new measure?

 

I need to create a new measure (outlined at the very bottom of this post) that calculates the difference between the following two measures, but each measure is filtered for different criteria. The first needs to be filtered for all lines within the same table where the Origin Territory column equals the Destination Territory column, for a chosen Origin Site Code (another column within the same table). The second needs to be filtered for the reverse; all lines where Origin Territory does NOT equal Destination Territory, for a chosen Destination Site Code (another column within the same table).

 

Measure 1: Local Average Cost per Unit

DIVIDE(
    CALCULATE(SUM(Cost),
        Origin Territory = Destination Territory
    ),
    CALCULATE(SUM(Quantity), 
        Origin Territory = Destination Territory
    )
)
 
Measure 2: Out of Market Average Cost per Unit
DIVIDE(
    CALCULATE(SUM(Cost),
        Origin Territory <> Destination Territory
    ),
    CALCULATE(SUM(Quantity),
        Origin Territory <> Destination Territory
    )
)
 
New Measure = Measure 1 filtered for Origin Site Code XXXX minus Measure 2 filtered for Destination Site Code XXXX (XXXX represents the same site code for both measures as well as for the new measure)
 
Thank you so much to anyone & everyone for your time and efforts
4 REPLIES 4
h21
Helper I
Helper I

Hi @miss-ness 
It will be helpful if you share sample date, so I will be able to provide you with proper measure to be used. 

This is an example of a table all three measures would be based on. There are a number of other columns also in this table but are either irrelevant here or would be filtered for the same criteria for all three measures. Does this help contextualize?

 

(You can see there may be multiple sites belonging to a single territory.)

 

 

DateOrigin SiteOrigin TerritoryDest. SiteDest. TerritoryQuantity
1/4/2021ABCDSouthMNOPNorth1
1/17/2021ABCD

South

QRSTNorth2
2/8/2021EFGH

West

UVWXSouth3
3/11/2021IJKLEastMNOPNorth2
3/17/2022EFGHWestUVWXSouth4

 

amustafa
Super User
Super User

Perhaps this might help...

 

New Measure = 
CALCULATE(
    [Local Average Cost per Unit],
    'Table'[Origin Site Code] = "XXXX",
    'Table'[Origin Territory] = 'Table'[Destination Territory]
)
-
CALCULATE(
    [Out of Market Average Cost per Unit],
    'Table'[Destination Site Code] = "XXXX",
    'Table'[Origin Territory] <> 'Table'[Destination Territory]
)




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

Proud to be a Super User!




Hi @amustafa , thanks so much for your response. The issue with this solution is that I will need a more dynamic measure that calculates across all Destination Site Codes, not only XXXX. 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.