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

Be 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

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.