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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
ghunt03
Frequent Visitor

Calculating the last non blank value not totaling correctly

I am trying to get the last non blank value from a table of entries by month. The issue I am having is I can't get the grand total to work correctly 

 

Estimated Cost @@ Completion - Last Reported = 
var minDate = MIN('Calendar'[Date])
var totalCost = CALCULATE (
    (SUM ( 'Work In Progress'[Cost] ) + SUM('Work In Progress'[CostAdjustment])),
    LASTNONBLANK ( FILTER(ALL(Calendar[Date]), 'Calendar'[Date] <= minDate), CALCULATE ( SUM ( 'Work In Progress'[Cost] ) +  SUM ( 'Work In Progress'[CostAdjustment] ) ) )
)

return totalCost

Screen Shot 2018-05-30 at 8.11.31 pm.png

I am using the minimum date because I am trying to calculate the last reported value for the selected period.

 

Screen Shot 2018-05-30 at 8.19.46 pm.png

 

Any help would be greatly appreciated

3 REPLIES 3
v-jiascu-msft
Employee
Employee

Hi @ghunt03,

 

Can you share the file? Please mask the private parts first.

Why did you use LASTNONBLANK?

Maybe the formula could work.

Estimated Cost @@ Completion - Last Reported = 
var minDate = MIN('Calendar'[Date])
var totalCost = 
    LASTNONBLANK ( FILTER(ALL(Calendar[Date]), 'Calendar'[Date] <= minDate), SUM ( 'Work In Progress'[Cost] ) +  SUM ( 'Work In Progress'[CostAdjustment] ) 
)

return totalCost

Best Regards,

Dale

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

Hi @v-jiascu-msft

 

I was using the LASTNONBLANK formula to find the latest reported value. The formula you suggested only seems to return a date

 

I have a copy of the file available at the following link

 

Example File

 

The other option I have tried is to lookup the Cost and Cost Adjusment value as there is only a maximum of one entry per month.  However I haven't been able to figure out the correct syntax for this one either

Hi @ghunt03,

 

I wonder if the solution below could help.

1. Create a new table "Contract" due to not all the contract exists in all the months.

Contract = DISTINCT(VALUES('Work In Progress'[Contract]))

2. Create a calculated table.

Result =
SUMMARIZECOLUMNS (
    Contract[Contract],
    'Work In Progress'[Mth],
    "value",
    VAR total =
        SUM ( 'Work In Progress'[Cost] ) + SUM ( 'Work In Progress'[CostAdjustment] )
    RETURN
        IF (
            ISBLANK ( total ),
            CALCULATE (
                (
                    SUM ( 'Work In Progress'[Cost] ) + SUM ( 'Work In Progress'[CostAdjustment] )
                ),
                LASTNONBLANK (
                    FILTER ( ALL ( 'Work In Progress'[Mth] ), 'Work In Progress'[Mth] <= [Mth] ),
                    CALCULATE (
                        SUM ( 'Work In Progress'[Cost] ) + SUM ( 'Work In Progress'[CostAdjustment] )
                    )
                )
            ),
            total
        )
)

3. Create a visual based on the new table.

Calculating_the_last_non_blank_value_not_totaling_correctly

 

Best Regards,

Dale

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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.