Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Need to manipulate context-based values

I have a dataset of software revenue by market and submarket. It spans multiple years, and I'm calculating year-over-year (YoY) change metrics. One of these involves the square of the YoY change in m...
  • OwenAuger's avatar
    5 years ago

    Hi Anonymous 

     

    If I've understood the requirements correctly, you want the squared YoY differences in market share summed by Vendor.

     

    I would suggest creating these measures:

     

    Vendor Market Share PY = 
    CALCULATE ( 
        [Vendor Market Share],
        SAMEPERIODLASTYEAR ( 'Market Data'[Year].[Date] )
        // 'Market Data'[Year].[Date] is used since there is an automatic
        // date hierarchy on the 'Market Data'[Year] column.
        // If you introduce a separate Date table,
        // you should instead use the Date column from that table
    )
    
    Vendor Market Share YoY = 
    VAR CurrentYear = 
        [Vendor Market Share]
    VAR PriorYear = 
        [Vendor Market Share PY]
    RETURN
        CurrentYear - PriorYear
        // You may want force the measure to return blank if PriorYear values don't exist
        // I haven't worried about this for now
    
    Sum of Squared Vendor Market Share YoY = 
    SUMX ( 
        VALUES ( 'Market Data'[Vendor] ),
        [Vendor Market Share YoY] ^ 2
    )

     

     

     Do these give the expected result?

     

    Regards,

    Owen