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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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