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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
luistiscornia
Regular Visitor

biannual comparative

Hi! What formula can I apply to be able to compare the period 2019 with the period 2017 since with the measurement 

CALCULATE([VOTOS TOTALES],SAMEPERIODLASTYEAR(Calendario[Año]=2017)) it throws me an error.
Thank you so much!2021-07-05 23_16_19-RESULTADOS_ELECTORALES2019y2017_COMPARATIVO_v3 - Power BI Desktop.png
1 ACCEPTED SOLUTION
v-kkf-msft
Community Support
Community Support

Hi @luistiscornia ,

 

The SAMEPERIODLASTYEAR function needs to reference a date/time column. You can try the following measure:

 

comparativa = 
CALCULATE(
    [VOTOS TOTALES], 
    FILTER(
        ALLSELECTED('Table'),
        'Table'[Year] = MAXX(
                            FILTER(
                                ALLSELECTED('Table'),
                                'Table'[Year] < MAX('Table'[Year])
                            ),
                            'Table'[Year]
                        )
    )
)

 image.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.

Best Regards,
Winniz

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

View solution in original post

2 REPLIES 2
v-kkf-msft
Community Support
Community Support

Hi @luistiscornia ,

 

The SAMEPERIODLASTYEAR function needs to reference a date/time column. You can try the following measure:

 

comparativa = 
CALCULATE(
    [VOTOS TOTALES], 
    FILTER(
        ALLSELECTED('Table'),
        'Table'[Year] = MAXX(
                            FILTER(
                                ALLSELECTED('Table'),
                                'Table'[Year] < MAX('Table'[Year])
                            ),
                            'Table'[Year]
                        )
    )
)

 image.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.

Best Regards,
Winniz

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

amitchandak
Super User
Super User

@luistiscornia , You want to compare two values selected in the year box?

 

example

 
measure 1=
VAR minDate = MINX( allselected('Calendar') , 'Calendar'[Year] )
VAR maxDate = MAXX(allselected('Calendar') , 'Calendar'[Year] )
RETURN
CALCULATE([VOTOS TOTALES], filter('Calendar', 'Calendar'[Year] =_max)) - CALCULATE([VOTOS TOTALES], filter('Calendar', 'Calendar'[Year] =_min))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Kudoed Authors