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

lookup value from table

Trying to write a Dax expression that calculates the variance between sales YTD minus sales prior year YTD

 

i have the measures written for sales YTD and sales prior year YTD.

 

i have no problem with an expression sales YTD - prior YTD.

 

my struggle is how do I incorporate a table value into the expression.

 

i want to treat revenue amounts different than expense amounts.

 

 

1 ACCEPTED SOLUTION
v-juanli-msft
Community Support
Community Support

Hi @Allpat64

According to your last post, it seems you have found the solution there.

Use this formula

YTD_Variance_Matrix =
CALCULATE (
    TOTALYTD (
        [MTD_Actuals_Matrix],
        V_FS_DIM_DATE[act_date]
    ) - TOTALYTD (
            [MTD_Budget_Matrix],
            V_FS_DIM_DATE[act_date]
        ),
    KPI_Finance_Matrix[Group] = "Revenue"   //a filter condition
) + (
        CALCULATE (
            TOTALYTD (
                [MTD_Budget_Matrix],
                V_FS_DIM_DATE[act_date]
            ) - TOTALYTD (
                    [MTD_Actuals_Matrix],
                    V_FS_DIM_DATE[act_date]
                ),
            KPI_Finance_Matrix[Group] = "Operating Expenses"
) )

As this example shown, you could use a Boolean expression as a filter in the function CALCULATE to change the context in which the data is filtered, and evaluates the expression in the new context that you specify.

Reference:

CALCULATE(<expression>,<filter1>,<filter2>…)

 

 

 

Best Regards

Maggie

 

 

Best Regards

Maggie

 

 

 

View solution in original post

2 REPLIES 2
v-juanli-msft
Community Support
Community Support

Hi @Allpat64

According to your last post, it seems you have found the solution there.

Use this formula

YTD_Variance_Matrix =
CALCULATE (
    TOTALYTD (
        [MTD_Actuals_Matrix],
        V_FS_DIM_DATE[act_date]
    ) - TOTALYTD (
            [MTD_Budget_Matrix],
            V_FS_DIM_DATE[act_date]
        ),
    KPI_Finance_Matrix[Group] = "Revenue"   //a filter condition
) + (
        CALCULATE (
            TOTALYTD (
                [MTD_Budget_Matrix],
                V_FS_DIM_DATE[act_date]
            ) - TOTALYTD (
                    [MTD_Actuals_Matrix],
                    V_FS_DIM_DATE[act_date]
                ),
            KPI_Finance_Matrix[Group] = "Operating Expenses"
) )

As this example shown, you could use a Boolean expression as a filter in the function CALCULATE to change the context in which the data is filtered, and evaluates the expression in the new context that you specify.

Reference:

CALCULATE(<expression>,<filter1>,<filter2>…)

 

 

 

Best Regards

Maggie

 

 

Best Regards

Maggie

 

 

 

Stachu
Community Champion
Community Champion

can you share the sample data in copiable format as well as the syntax for your measures?

you can find advice how to post these here

https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

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.