Forum Discussion

meridian59's avatar
meridian59
New Member
3 years ago

Stumped by measure, please help!

Hi,

 

I'm really struggling with this power BI thing, don't think I've ever done anything as frustrating!

The variable Rate1 in a regular Matrix table returns 1.25 which is correct once the slicers are applied. However when I try to use the variable within the result variable, it seems to zero out the calculation? I'm so confused!

 

Another question, is there any functionality in BI where you can test out each step in the calculation? Similar to the step macro in Visual basic in excel?

 

Any help would be appreciatted as my hair will fall out soon trying to work this out!

 

 

 

 

ExpectedValVarv3Sales = VAR Comparator1RateGBP = 
                    SWITCH( TRUE(),
                    VALUES(m_Comparator1[Comparator1]) = "Actuals", sumx(filter(f_ExpectedValues,f_ExpectedValues[Account#]="Comparator1" && f_ExpectedValues[Scenario#]="Actual" && f_ExpectedValues[Value#]="GBP TOTAL" && f_ExpectedValues[Category]="Sales"),[Amount]),
                    VALUES(m_Comparator1[Comparator1]) = "Budget 22", sumx(filter(f_ExpectedValues,f_ExpectedValues[Account#]="Comparator1" && f_ExpectedValues[Scenario#]="Budget22" && f_ExpectedValues[Value#]="GBP TOTAL" && f_ExpectedValues[Category]="Sales"),[Amount]),
                    VALUES(m_Comparator1[Comparator1]) = "Q2 Forecast", sumx(filter(f_ExpectedValues,f_ExpectedValues[Account#]="Comparator1" && f_ExpectedValues[Scenario#]="Q2Forecast" && f_ExpectedValues[Value#]="GBP TOTAL" && f_ExpectedValues[Category]="Sales"),[Amount]),
                    VALUES(m_Comparator1[Comparator1]) = "Q3 Forecast", sumx(filter(f_ExpectedValues,f_ExpectedValues[Account#]="Comparator1" && f_ExpectedValues[Scenario#]="Q3Forecast" && f_ExpectedValues[Value#]="GBP TOTAL" && f_ExpectedValues[Category]="Sales"),[Amount]),
                    VALUES(m_Comparator1[Comparator1]) = "Q4 Forecast", sumx(filter(f_ExpectedValues,f_ExpectedValues[Account#]="Comparator1" && f_ExpectedValues[Scenario#]="Q4Forecast" && f_ExpectedValues[Value#]="GBP TOTAL" && f_ExpectedValues[Category]="Sales"),[Amount]),
                    BLANK())

                    VAR Comparator1RateUSD = 
                    SWITCH( TRUE(),
                    VALUES(m_Comparator1[Comparator1]) = "Actuals", sumx(filter(f_ExpectedValues,f_ExpectedValues[Account#]="Comparator1" && f_ExpectedValues[Scenario#]="Actual" && f_ExpectedValues[Value#]="USD TOTAL" && f_ExpectedValues[Category]="Sales"),[Amount]),
                    VALUES(m_Comparator1[Comparator1]) = "Budget 22", sumx(filter(f_ExpectedValues,f_ExpectedValues[Account#]="Comparator1" && f_ExpectedValues[Scenario#]="Budget22" && f_ExpectedValues[Value#]="USD TOTAL" && f_ExpectedValues[Category]="Sales"),[Amount]),
                    VALUES(m_Comparator1[Comparator1]) = "Q2 Forecast", sumx(filter(f_ExpectedValues,f_ExpectedValues[Account#]="Comparator1" && f_ExpectedValues[Scenario#]="Q2Forecast" && f_ExpectedValues[Value#]="USD TOTAL" && f_ExpectedValues[Category]="Sales"),[Amount]),
                    VALUES(m_Comparator1[Comparator1]) = "Q3 Forecast", sumx(filter(f_ExpectedValues,f_ExpectedValues[Account#]="Comparator1" && f_ExpectedValues[Scenario#]="Q3Forecast" && f_ExpectedValues[Value#]="USD TOTAL" && f_ExpectedValues[Category]="Sales"),[Amount]),
                    VALUES(m_Comparator1[Comparator1]) = "Q4 Forecast", sumx(filter(f_ExpectedValues,f_ExpectedValues[Account#]="Comparator1" && f_ExpectedValues[Scenario#]="Q4Forecast" && f_ExpectedValues[Value#]="USD TOTAL" && f_ExpectedValues[Category]="Sales"),[Amount]),
                    BLANK())

                    VAR Rate1 = 
                            Comparator1RateUSD / Comparator1RateGBP

                    VAR Result = 
                    sumx(filter(f_ExpectedValues,f_ExpectedValues[Category]="Sales"),
                            if(and(f_ExpectedValues[Account#]="Comparator1",f_ExpectedValues[Category]="Sales"),if(values(d_Values[Value#])="GBP TOTAL",m_Comparator1[Comparator1ExpValuesGBP],m_Comparator1[Comparator1ExpValuesUSD]),
                            if(and(f_ExpectedValues[Account#]="Comparator2",f_ExpectedValues[Category]="Sales"),if(values(d_Values[Value#])="GBP TOTAL",m_Comparator2[Comparator2ExpValuesGBP],m_Comparator2[Comparator2ExpValuesUSD]),
                                if(values(d_Values[Value#])="GBP TOTAL",
                                    [Comparator2ExpValuesGBP]-[Comparator1ExpValuesGBP],
                                        ([Comparator2ExpValuesGBP]-[Comparator1ExpValuesGBP])*Rate1
                                        ))))

                    RETURN Result

 

 

 

2 Replies