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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
John_Silva642
Frequent Visitor

CALCULATE filtered by LASTDATE

Hello,

I'm having a problem using the measure CALCULATE filtering by a text value, and the LASTDATE.
Can someone help me, please?

This is the expression:

VAR DATAMAX =
LASTDATE('F&A'[Data])
VAR RESULT =
CALCULATE(
SUM('F&A'[Valor]),
'F&A'[Informações] = "Iniciativas Entregues",
DATAMAX
)
RETURN
RESULT
TableTableMeasureMeasure
The result should be 3, but the measure brings the soma of all values (2+3=5).
How can I fix this problem?
2 ACCEPTED SOLUTIONS

This is likely because DATAMAX isn't "Iniciativas Entregues".

 

If you want the last date for that specific text filter, then you'll need to modify your measure.

VAR DATAMAX =
    CALCULATE (
        LASTDATE ( 'F&A'[Data] ),
        'F&A'[Informações] = "Iniciativas Entregues"
    )
VAR RESULT =
    CALCULATE (
        SUM ( 'F&A'[Valor] ),
        'F&A'[Informações] = "Iniciativas Entregues",
        'F&A'[Data] = DATAMAX
    )
RETURN
    RESULT

View solution in original post

Thanks, @AlexisOlson!

Problem solved!

John_Silva642_0-1638049001691.png

 




View solution in original post

6 REPLIES 6
AlexisOlson
Super User
Super User

You're almost there.

 

Try this:

VAR DATAMAX = LASTDATE ( 'F&A'[Data] )
VAR RESULT =
    CALCULATE (
        SUM ( 'F&A'[Valor] ),
        'F&A'[Informações] = "Iniciativas Entregues",
        'F&A'[Data] = DATAMAX
    )
RETURN
    RESULT

It's returning a blank value now.

Attempt1Attempt1Attempt MeasureAttempt Measure

This is likely because DATAMAX isn't "Iniciativas Entregues".

 

If you want the last date for that specific text filter, then you'll need to modify your measure.

VAR DATAMAX =
    CALCULATE (
        LASTDATE ( 'F&A'[Data] ),
        'F&A'[Informações] = "Iniciativas Entregues"
    )
VAR RESULT =
    CALCULATE (
        SUM ( 'F&A'[Valor] ),
        'F&A'[Informações] = "Iniciativas Entregues",
        'F&A'[Data] = DATAMAX
    )
RETURN
    RESULT

Thanks, @AlexisOlson!

Problem solved!

John_Silva642_0-1638049001691.png

 




Hi,

Share the link from where i can download your PBI file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thanks, @Ashish_Mathur!

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.