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
admiralman
Advocate II
Advocate II

Use measure within another measure

I have the following measures and I need a new measure called Net that is CurrentYear - PriorYear. Can I create this measure without repeating the formulas of the prior two...something like [CurrentYear] - [PriorYear] or something? All three of these will be used in a matrix with values over 12 months. Thanks.

 

CurrentYear = Format(
CALCULATE(sum(Sheet1[FinancialAmount]), filter(Sheet1, Sheet1[FinancialType]= "Current")),
"$#,##0;($#,##0)"
)

 

PriorYear = Format(
CALCULATE(sum(Sheet1[FinancialAmount]), filter(Sheet1, Sheet1[FinancialType]= "Prior")),
"$#,##0;($#,##0)"
)

1 ACCEPTED SOLUTION
Thyago_Rezende
Resolver I
Resolver I

Hi @admiralman,

 

Try to do VARIABLES within measures like below:

 

% YoY Sales = 

VAR CURRENT_SALES = SUM(SALES)

VAR PRIOR_SALES = CALCULATE(SUM(SALES);SAMEPERIODLASTYEAR(DATES))

Return

DIVIDE ( CURRENT_SALES - PRIOR_SALES; PRIOR_SALES)

 

Best regards,

View solution in original post

3 REPLIES 3
Thyago_Rezende
Resolver I
Resolver I

Hi @admiralman,

 

Try to do VARIABLES within measures like below:

 

% YoY Sales = 

VAR CURRENT_SALES = SUM(SALES)

VAR PRIOR_SALES = CALCULATE(SUM(SALES);SAMEPERIODLASTYEAR(DATES))

Return

DIVIDE ( CURRENT_SALES - PRIOR_SALES; PRIOR_SALES)

 

Best regards,

ricardocamargos
Continued Contributor
Continued Contributor

Hi @admiralman,

 

Once you have created measures you can use them inside others measures. Also you can change the context of them.

 

Thanks,

 

Ricardo

Thanks...I came in today and looked at my question. I think I was trying to do something a little more complicated and didnt address the question correctly. I know you can do that with measures...must have had a brain f@rt. Thanks.

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.