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

Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more

Reply
bvdm1980
Helper II
Helper II

need for last date with data for a project

So i'm back with another Q. I thought i had it working properly, untill there came an exception which made clear my dax isn't returning the correct data. 

What is have, is a table with 1 column being the values of a measure, where the individual values are correct, but the total below the table for this column, isnt correct. If you sum the TT resultaat per datum column you will see it should total to 6.203.000 and not to 6.184.000, the difference is the 19k line for project 411490. And as you can see, the last column on right shows different date as the last result for this project was booked at 30-6-2024, where rest is 31-8-2024. 

 

Schermafbeelding 2024-10-03 095416.png

 

The total of the column is just the standard total from the visual settings. No calculated total or whatsoever. But apparently it does show the project result for this one on individual line, which is correct, but it doesn't included it in the total of the column...

I used this formula: 

TT resultaat per datum =
    CALCULATE(
        sum('tussentijds resultaat'[Gecorrigeerd tussentijds resultaat]) + sum('tussentijds resultaat'[Gecorrigeerde verliesvoorziening]),
        LASTDATE('tussentijds resultaat'[Boekingsdatum]))
 
where it goes wrong with the red marked part. It takes as last date the booking date of the monthly result table. But apparently it takes 31-8-2024 and doesn't look at the individual results per project, which can be before that date. 

So how do i solve this, so that the 19k gets included in the total? It seems so weird that making an automated total, doesn't ad up the individual values...
1 ACCEPTED SOLUTION
v-kaiyue-msft
Community Support
Community Support

Hi @bvdm1980 ,

 

Based on your description, I created this data:

vkaiyuemsft_0-1728007301536.png

 


There are two methods to choose from here:

Measure = 
VAR _mindate =
    CALCULATE ( MIN ( 'Table'[Boekingsdatum] ), ALLSELECTED ( 'Table' ) )
RETURN
    CALCULATE (
        SUM ( 'Table'[Gecorrigeerd tussentijds resultaat] )
            + SUM ( 'Table'[Gecorrigeerde verliesvoorziening] ),
        'Table'[Boekingsdatum] >= _mindate
    )

 

Measure 2 = 
SUMX(
    'Table',
    CALCULATE(
        SUM('Table'[Gecorrigeerd tussentijds resultaat]) + 
        SUM('Table'[Gecorrigeerde verliesvoorziening]),
        LASTDATE('Table'[Boekingsdatum])
    )
)

 

vkaiyuemsft_1-1728007341802.png

If your Current Period does not refer to this, please clarify in a follow-up reply.

 

Best Regards,

Clara Gong

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
v-kaiyue-msft
Community Support
Community Support

Hi @bvdm1980 ,

 

Based on your description, I created this data:

vkaiyuemsft_0-1728007301536.png

 


There are two methods to choose from here:

Measure = 
VAR _mindate =
    CALCULATE ( MIN ( 'Table'[Boekingsdatum] ), ALLSELECTED ( 'Table' ) )
RETURN
    CALCULATE (
        SUM ( 'Table'[Gecorrigeerd tussentijds resultaat] )
            + SUM ( 'Table'[Gecorrigeerde verliesvoorziening] ),
        'Table'[Boekingsdatum] >= _mindate
    )

 

Measure 2 = 
SUMX(
    'Table',
    CALCULATE(
        SUM('Table'[Gecorrigeerd tussentijds resultaat]) + 
        SUM('Table'[Gecorrigeerde verliesvoorziening]),
        LASTDATE('Table'[Boekingsdatum])
    )
)

 

vkaiyuemsft_1-1728007341802.png

If your Current Period does not refer to this, please clarify in a follow-up reply.

 

Best Regards,

Clara Gong

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.

Kedar_Pande
Super User
Super User

Updated Measure

TT resultaat per datum =
CALCULATE(
SUM('tussentijds resultaat'[Gecorrigeerd tussentijds resultaat]) +
SUM('tussentijds resultaat'[Gecorrigeerde verliesvoorziening]),
FILTER(
'tussentijds resultaat',
'tussentijds resultaat'[Boekingsdatum] <= MAX('tussentijds resultaat'[Boekingsdatum])
)
)

 

yeah that is sometimes where i don't understand the logics of dax. 

You compare the same column from the same table, where (in my logic) it just says that date should be equal or smaller than that same date...

So why and how does this do the trick? 

Thanks for your reply btw! Much appreciated 🙂

The LASTDATE function returns the latest date in the context of your visual, which might not always reflect the correct date for individual projects.

By using MAX - you ensure that the measure looks at the correct date range for each project individually rather than relying on the overall context of the visual.

 

If this helped, a Kudos 👍 or Solution mark would be great!
Cheers,
Kedar Pande
www.linkedin.com/in/kedar-pande

the error seems to be in that "last ttr" column, which is a measure that returns the last date where a result was booked from the table "tussentijds resultaat". 

The total of the "tt resultaat per datum" column should include all projects that have last booked result date. And now it only includes project results with last date 31-8-2024.

But if i try to include that in my dax, it gives errors or totally different values. 

Oh it doesn't solve the trick tbh

gives me total different values per project and in total. 

Helpful resources

Announcements
PBIApril_Carousel

Power BI Monthly Update - April 2025

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

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

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

Top Solution Authors