Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
RajeshPBI
Frequent Visitor

Value Stored in a Variable is different when used in another Variable

Hi,

I am defining a measure as below (Code Below).

Revenue For the first month is calculated as Budget Amount($139,000) multiplied by a cost % (8.21% in this case) and is stored in a variable PeriodOneRevRec. The value of the above is $11,408.

For the next month calculation, i need to subract $11,408 (first Month Revenue) from $139,000 (The Budget Amount). I do this in another variable NetBudgetYearOne. The output i was expecting is 127,592 ($139,000 - $11,408) but the output i am getting is $121,706. Measure Code and Picture of the visual is below. I have also identfied the difference between what is displayed when compared to what is expected, but i do not know why this is happening and hence unable to fix the problem. Reques help on this.

RRR Period Measure =

CALCULATE(

VAR Period=
SELECTEDVALUE('MS Calendar'[Month Year]) -- Value for the Respective Period used in a table visual with Month Year column from

                                                                             the custom calendar First Period Jun 2023. When i return this, the values are correct

VAR CostPerc=
[Actual Cost % To Forecast] -- Measure working fine. Formula is Cost for the month divided by total cost (Cost for the month plus       

                                                sum of future costs). When i return this, the values are correct for all month

VAR StartDate=
FORMAT(MIN('Project Master'[Start Date]),"MMM YYYY") -- Jun 2023. When i return this, the value is correct.

VAR BUDGETAMOUNT =
SUM('Project Master'[Fixed Fee/Cap]) -- $139,000. When i return this the value is correct

VAR PeriodOneRevRec =
[RR 1st Period Rev]--,FILTER('MS Calendar',CurrentPeriod=StartDate)) -- $11,408 (8.21% * 139000). Measure and When i return this,

                                                                                                               this value is showing correctly.

                                                                                                               

VAR PeriodTwo=
FORMAT(EDATE(DATEVALUE("1 " & StartDate),1),"MMM YYYY") --Jul 2023. Showing Correctly for Jul 2023

VAR NetBudgetYearOne=IF(Period=PeriodTwo,(BUDGETAMOUNT-PeriodOneRevRec)) -- Should be $127,592 ($139,000 - $11,408)

                                                                                                                                     Output is $121,706 (this is where the problem is)

VAR PeriodTwoRevRec = NetBudgetYearOne * [Actual Cost % To Forecast] -- 12.44% * $121,706: Instead of 127592. The difference 

                                                                                                                            between 127592 and 121706 is 5886 (17293-11408)
Return

NetBudgetYearOne
--IF(Period=StartDate,PeriodOneRevRec,IF(Period=PeriodTwo,PeriodTwoRevRec))
)
The difference of 5886 is $17293 which is (139000*8.21% [Budget Amount * Cost Percent of June 2023-Month One] Less $11408 which is (139000*12.44% [Budget Amount * Cost Percent of Jul 2023-Month Two].

 

I am relatively new to DAX. I do understand that i have made a mistake somewhere as the output is only reflecting the written code, but i am unable to identify where the problem.

IMG_2581.jpg

 

Pls do help.

 

Regards

1 REPLY 1
lbendlin
Super User
Super User

Please provide sample data (with sensitive information removed) that covers your issue or question completely, in a usable format (not as a screenshot). Leave out anything not related to the issue.
If you are unsure how to do that please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Please show the expected outcome based on the sample data you provided.

If you want to get answers faster please refer to https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.