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
david230796
Frequent Visitor

Semi-additive balances interacting in different tables

Hi All,

 

Relatively new to the Power BI journey but really enjoying the problem-solving so far. Run into a bit of a roadblock however and hope I can get some help from this amazing community:

 

Scenario:

I have a number of products which are valued quarterly. These are semi-additive in that I want to sum their individual values on each day to get my portfolio's value but I don't want to sum these values on different dates as they are effectively balances. In order to show the value of the portfolio on dates that can be filtered, I have created a measure ("Most Recent Valuation") to calculate the most recent valuation of each product.

 

This measure is working well however my problem comes where there are some products which have been sold and therefore I don't want to include them in the most recent valuation after a certain date (the date they were sold). I need them to appear in the portfolio valuations right up until the date they were sold and then not to be included thereafter.

 

I have a table which lists out when the products were disposed of and I have created a calculated column to get the last relevant valuation date for each of the products - in the hope that I would be able to include that in my measure to filter out results after that. I've been pretty unsuccessful in that and so any pointers on this would be really appreciated.

 

I have a dates table as well as the two tables mentioned above - shown below:

 

Valuations

Product ReferenceDateValuation
A30-Jun-2020100
B30-Jun-2020200
C30-Jun-2020300
A30-Sep-2020150
C30-Sep-2020350

 

Disposals

Product ReferenceDate of DisposalDate of Last Valuation
B19-Jul-202030-Jun-2020

 

 

Most Recent Valuation = 
VAR MaxDate =
    MAX ( 'Dates'[Date] )
VAR LastDates =
    ADDCOLUMNS (
        CALCULATETABLE (
            VALUES ( Valuations[Product Reference] ),
            ALL ( 'Dates' )
        ),
        "LastDay", CALCULATE (
            MAX ( Valuations[Date] ),
            ALL ( 'Dates' ),
            'Dates'[Date] <= MaxDate
        )
    )
VAR LastDatesWithLineage =
    TREATAS (
        LastDates,
        Valuations[Product Reference],
        'Dates'[Date]
    )
VAR Result =
    CALCULATE (
        SUM ( Valuations[Valuation]),
        LastDatesWithLineage
    )
RETURN
    Result

 

 

At the moment the measure above returns the following matrix:

Product ReferenceMost Recent Valuation
A150
B200
C350

 

I essentially want to find a way to exclude B from the results for 30 September 2020, while keeping it included in 30 June 2020.

 

Thanks for reading this, hope someone can help.

1 ACCEPTED SOLUTION
DataInsights
Super User
Super User

@david230796,

 

Try this measure:

 

Most Recent Valuation = 
VAR vSlicerDate =
    MAXX ( ALLSELECTED ( Dates ), Dates[Date] )
VAR vProductMaxDateInScope =
    CALCULATE (
        MAX ( Valuations[Date] ),
        ALL ( Dates ),
        Valuations[Date] <= vSlicerDate
    )
VAR vProductValuation =
    CALCULATE (
        SUM ( Valuations[Valuation] ),
        ALL ( Dates ),
        Valuations[Date] = vProductMaxDateInScope
    )
VAR vResult =
    IF ( MAX ( Valuations[Date] ) = vProductMaxDateInScope, vProductValuation )
RETURN
    vResult

 

 

DataInsights_0-1608081297408.png

 

DataInsights_1-1608081310276.png

 





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

Proud to be a Super User!




View solution in original post

2 REPLIES 2
david230796
Frequent Visitor

Thanks so much @DataInsights - that's working perfectly. Really appreciate your time and effort.

DataInsights
Super User
Super User

@david230796,

 

Try this measure:

 

Most Recent Valuation = 
VAR vSlicerDate =
    MAXX ( ALLSELECTED ( Dates ), Dates[Date] )
VAR vProductMaxDateInScope =
    CALCULATE (
        MAX ( Valuations[Date] ),
        ALL ( Dates ),
        Valuations[Date] <= vSlicerDate
    )
VAR vProductValuation =
    CALCULATE (
        SUM ( Valuations[Valuation] ),
        ALL ( Dates ),
        Valuations[Date] = vProductMaxDateInScope
    )
VAR vResult =
    IF ( MAX ( Valuations[Date] ) = vProductMaxDateInScope, vProductValuation )
RETURN
    vResult

 

 

DataInsights_0-1608081297408.png

 

DataInsights_1-1608081310276.png

 





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

Proud to be a Super User!




Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.