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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Bunmz_a
Frequent Visitor

Problem with Grand Total of Measure in HASONEVALUE

Please I am experiencing a challenge with my DAX measure

 

My objective is to calculate the total budget associated with each Workorder status however for Projected Workorders, the budget for Open and Initiated should be netted off till it gets to 0. Meaning the Budget measure would need to incorporate an adjustment for Projected Workorders

 

I have been able to do this successfully but the grand total does not work.

 

For the grand total, I am still getting a sum that reflect the original not adjusted projected budget regardless of the logic built into the measure

 

Below is my measure. When I use ‘HASONEVALUE’ I get 0 as the grand total

 

Please help

 

 

Budget =

VAR WOstatus =

    FIRSTNONBLANK ( 'Projected WO'[WO_Status], 1 )

 

VAR BudgetTotal =

    CALCULATE (

        SUM ( Budget[Amount] ),

        FILTER ( Budget, Budget[BudgetType] = "Budget" )

    )

   

VAR ProjectedAmount =

    CALCULATE (

        BudgetTotal,

        'Projected WO'[WO_Status] IN { "Projected", "projected" }

    )

 

VAR InitiatedAmount =

    CALCULATE (

        BudgetTotal,

        'Projected WO'[WO_Status] IN { "Initiated", "initiated" }

    )

 

VAR OpenAmount =

    CALCULATE (

        BudgetTotal,

        'Projected WO'[WO_Status] IN { "open", "Open" }

    )

 

VAR AdjustedProjectedAmount = MAX( (ProjectedAmount - InitiatedAmount - OpenAmount ), 0)

 

RETURN

    IF (

        NOT ( WOstatus IN { "Projected", "projected" } ),

        BudgetTotal,

        AdjustedProjectedAmount)

6 REPLIES 6
Anonymous
Not applicable

Hi @Bunmz_a ,

 

Please try:

BudgetCorrectTotal =
VAR IsProjected =
    HASONEVALUE ( 'Projected WO'[WO_Status] )
        && VALUES ( 'Projected WO'[WO_Status] ) IN { "Projected", "projected" }
VAR AdjustedProjectedAmount =
    IF (
        IsProjected,
        MAX ( ( [ProjectedAmount] - [InitiatedAmount] - [OpenAmount] ), 0 ),
        [BudgetTotal]
    )
RETURN
    IF (
        ISINSCOPE ( 'Projected WO'[WO_Status] ),
        AdjustedProjectedAmount,
        SUMX (
            VALUES ( 'Projected WO'[WO_Status] ),
            [AdjustedProjectedAmount]
        )
    )

 

I would be grateful if you could provide me with sample data with the personal information erased.

 

If you have any further questions please feel free to contact me.

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

Unfortunately, it didnt work.

 

The screenshot below shows what the issue is. Unfortunately I cant attched the PBIX as I dont see the option to here

 

Bunmz_a_0-1709569341813.png

 

Anonymous
Not applicable

Hi @Bunmz_a ,

 

You mean "Revised Budget" should be "$20,935,403" instead of "$20,946,636". I hope I understand correctly.

 

Please try:

 

Revised Budget = 
VAR WOstatus =
    FIRSTNONBLANK ( 'Projected WO'[WO Status], 1 )

VAR BudgetTotal =
    CALCULATE (
        SUM ( 'Workorder Data'[Budget (With Projected Adjustment)]))

    
VAR ProjectedAmount =
    CALCULATE (
        BudgetTotal,
        'Projected WO'[WO Status] IN { "Projected", "projected" }
    )

VAR InitiatedAmount =
    CALCULATE (
        BudgetTotal,
        'Projected WO'[WO Status] IN { "Initiated", "initiated" }
    )

VAR OpenAmount =
    CALCULATE (
        BudgetTotal,
        'Projected WO'[WO Status] IN { "open", "Open" }
    )

VAR AdjustedProjectedAmount = MAX( (ProjectedAmount - InitiatedAmount - OpenAmount ), 0)

RETURN
    IF (
        NOT ( WOstatus IN { "Projected", "projected" } ),
        BudgetTotal,
        AdjustedProjectedAmount
    )

 

vhuijieymsft_0-1709875463051.png

 

pbix file is attached.

 

If you have any further questions please feel free to contact me.

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

Hi Sorry for the late response. 

this is not the solution as the Budget Total uses the column that already has the answers (which was just for illustrative purposes). 

in the original problem, Budget with Adjusted Projected Amount does not exist. 

Sahir_Maharaj
Super User
Super User

Hello @Bunmz_a,

 

Can you please try the following DAX:

Adjusted Budget = 
VAR BudgetTotal = 
    CALCULATE (
        SUM ( Budget[Amount] ),
        Budget[BudgetType] = "Budget"
    )
VAR ProjectedAmount = 
    CALCULATE (
        BudgetTotal,
        'Projected WO'[WO_Status] IN { "Projected", "projected" }
    )
VAR InitiatedAmount = 
    CALCULATE (
        BudgetTotal,
        'Projected WO'[WO_Status] IN { "Initiated", "initiated" }
    )
VAR OpenAmount = 
    CALCULATE (
        BudgetTotal,
        'Projected WO'[WO_Status] IN { "Open", "open" }
    )
VAR AdjustedProjectedAmount = 
    MAX( ProjectedAmount - InitiatedAmount - OpenAmount, 0 )
VAR IsTotal = 
    ISINSCOPE('Projected WO'[WO_Status])

RETURN
    IF (
        IsTotal,
        SUMX(
            VALUES('Projected WO'[WO_Status]),
            IF (
                'Projected WO'[WO_Status] IN { "Projected", "projected" },
                AdjustedProjectedAmount,
                BudgetTotal
            )
        ),
        IF (
            'Projected WO'[WO_Status] IN { "Projected", "projected" },
            AdjustedProjectedAmount,
            BudgetTotal
        )
    )

Hope this helps.


Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution? (Yes, its FREE!)
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

Hi Sahir, it didn't work. I ended up with the same grand total which still reflects the original projected budget 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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