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
Anonymous
Not applicable

New calculated column using row context to select value from same table

 

I have a table showing yearly Sales and Profit values at specific years for two different companies:

 

2018-08-28_120532.png

Another table specifies reference years for each company.

 

 

2018-08-28_120651.png

 

 

I would like a DAX expression to calculate a new column "Value_at_RefYear" showing for each company the Sales and Profit at reference year as specified in the RefYear table:

 

2018-08-28_121809.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Thanks for any help on this!

 

Karim

 

 

1 ACCEPTED SOLUTION
Zubair_Muhammad
Community Champion
Community Champion

@Anonymous

 

Try with this column

 

Value at Ref Year Column =
CALCULATE (
    SUM ( Sales_and_Profit[Value] ),
    FILTER (
        ALLEXCEPT (
            Sales_and_Profit,
            Sales_and_Profit[Company],
            Sales_and_Profit[Attribute]
        ),
        Sales_and_Profit[Year] = RELATED ( RefYear[Year] )
    )
)

Regards
Zubair

Please try my custom visuals

View solution in original post

2 REPLIES 2
Zubair_Muhammad
Community Champion
Community Champion

@Anonymous

 

Try with this column

 

Value at Ref Year Column =
CALCULATE (
    SUM ( Sales_and_Profit[Value] ),
    FILTER (
        ALLEXCEPT (
            Sales_and_Profit,
            Sales_and_Profit[Company],
            Sales_and_Profit[Attribute]
        ),
        Sales_and_Profit[Year] = RELATED ( RefYear[Year] )
    )
)

Regards
Zubair

Please try my custom visuals
Anonymous
Not applicable

Hi Zubair,

 

Thanks, it worked perfectly and also helped me understand a bit more about the combined use of the CALCULATE and FILTER functions.

 

Cheers

 

Karim

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.