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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
luizahenriques
Frequent Visitor

How to sort filters in calculate

Hello everyone!

 

I need to put the last value of "Média Móvel" measure in another measure called "Forecast". I got it but i wont't like to see this valuye "78.116,71" in past months. I'd like to see only in the forecast months(since 2022-novembro).

 

Measure

 

-----

Forecast =
VAR ultimoDiaComValor = CALCULATE(MAX('fDados Gerais dos Contratos SAMC'[Data Fim]),ALL('fDados Gerais dos Contratos SAMC'))

RETURN  
CALCULATE(Medidas[Média Móvel],FILTER(ALLSELECTED('dCalendário'[Date]),'dCalendário'[Date]=ultimoDiaComValor))
------

Can someone help me?

 

luizahenriques_0-1669830292680.png

 

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @luizahenriques ,

 

Try to change your metric to:

Forecast =
VAR ultimoDiaComValor =
    CALCULATE (
        MAX ( 'fDados Gerais dos Contratos SAMC'[Data Fim] ),
        ALL ( 'fDados Gerais dos Contratos SAMC' )
    )
RETURN
    IF (
        MAX ( 'dCalendário'[Date] ) > EOMONTH ( ultimoDiaComValor, 0 ),
        CALCULATE (
            Medidas[Média Móvel],
            FILTER (
                ALLSELECTED ( 'dCalendário'[Date] ),
                'dCalendário'[Date] = ultimoDiaComValor
            )
        )
    )

 

This will compare the maximum date on that specific line with the value of the end of month your last contratos if it's higher then it will retun the value if not it will be blank.

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

1 REPLY 1
MFelix
Super User
Super User

Hi @luizahenriques ,

 

Try to change your metric to:

Forecast =
VAR ultimoDiaComValor =
    CALCULATE (
        MAX ( 'fDados Gerais dos Contratos SAMC'[Data Fim] ),
        ALL ( 'fDados Gerais dos Contratos SAMC' )
    )
RETURN
    IF (
        MAX ( 'dCalendário'[Date] ) > EOMONTH ( ultimoDiaComValor, 0 ),
        CALCULATE (
            Medidas[Média Móvel],
            FILTER (
                ALLSELECTED ( 'dCalendário'[Date] ),
                'dCalendário'[Date] = ultimoDiaComValor
            )
        )
    )

 

This will compare the maximum date on that specific line with the value of the end of month your last contratos if it's higher then it will retun the value if not it will be blank.

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors