March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
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
Hi @meridian59
the variables you have created follow certain conditions and filter contexts to outcome the 1.25 in your Matrix. Therefore you will need to verify seperatly the "Comparator1RateGBP" under which context and for which of the TRUE() VALUES() it returns 0 to know what filter is causing it.
Regards
Amine Jerbi
If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook
@meridian59 If you return Rate1 in your calculation and it returns 1.25 then that's not it. Sorry, having trouble following, can you post sample data as text and expected output?
Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882
Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490
The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
124 | |
87 | |
86 | |
70 | |
51 |
User | Count |
---|---|
205 | |
153 | |
97 | |
79 | |
69 |