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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
svishwanathan
Helper III
Helper III

Help with VAR formula

Hello

I have a functioning measure that refers to several measures from outside.  This is the functioning measure

Projected Cost (Input):=If(HASONEVALUE('Job-Phase'[JHP_OBJECT_ORASEQ]),[Old Projected Cost (Input)],SUMX(VALUES('Job-Phase'[JHP_OBJECT_ORASEQ]),CALCULATE(([Old Projected Cost (Input)]))))

 

I am trying to bring in the Old Projected Cost(input) as variable in the new formula

 

Projected Cost2(Input) :=
VAR ProjectedQuantitywithfilter =
    IF (
        [Quantity] > [Actual Output Quantity - To Date],
        [Quantity],
        [Actual Output Quantity - To Date]
    )
VAR RemainingQty = ProjectedQuantitywithfilter - [Actual Output Quantity - To Date]
VAR ProjectedCostInputwithfiltercontext =
    IF (
        ( RemainingQty * [Unit Cost - To Date] ) + [Actual Input Cost - To Date] = 0,
        [Current Budget Cost (Input)] + [Unposted PCI Cost (Input)],
        ( RemainingQty * [Unit Cost - To Date] ) + [Actual Input Cost - To Date]
    )
VAR ProjectedCostInputwithoutfiltercontext =
    SUMX (
        VALUES ( 'Job-Phase'[JHP_OBJECT_ORASEQ] ),
        CALCULATE ( ProjectedCostInputwithfiltercontext )
    )
RETURN
    IF (
        HASONEVALUE ( 'Job-Phase'[JHP_OBJECT_ORASEQ] ),
        ProjectedCostInputwithfiltercontext,
        ProjectedCostInputwithoutfiltercontext
    )
 
 
The measure fails when there is no filter context:JHP_OBJECT_ORASEQ.
Can anyone help me tweak this measure
2 REPLIES 2
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @svishwanathan ,

Have you solved your problem?

If you have solved, please always accept the replies making sense as solution to your question so that people who may have the same question can get the solution directly.

If you still need help, please share your data sample so that I could make a test on it.

Best  Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @svishwanathan ,

I still have a little confused about your scenario, which measure do you have problem? Projected Cost2(Input) or Old Projected Cost(input) as variable ? 

It seems that there is no syntax error for your formulas.

If it is convenient could you share some data sample and your desired output so that we could help further on it? Or, ideally, share the pbix (beware of confidential data)

Best Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.