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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

Compare the count of values from last year month to current year month for all month in Matrix

Hello,

 

 new to powe bi, i need to compare last year month count to presene year count, if value increase need to show arrow mark should be up, if decrease arrow should be down in conditional formatepbi community.png

 

when i use date date add, parallell period, privious month it will compare with in the year of month it won't give result last year month screen shot below

 

 

pmi community 2.png

 

pls help me sort out this issue

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

 

Use a single slicer and create two measures like below:

current_year_month =
CALCULATE (
    COUNT ( 'table'[value] ),
    FILTER (
        ALLSELECTED ( 'table' ),
        'table'[plant] = SELECTEDVALUE ( 'table'[plant] )
            && YEAR ( 'table'[date] ) = YEAR ( SELECTEDVALUE ( 'table'[date] ) )
            && MONTH ( 'table'[date] ) = MONTH ( SELECTEDVALUE ( 'table'[date] ) )
    )
)

Last_year_month =
CALCULATE (
    COUNT ( 'table'[value] ),
    FILTER (
        ALLSELECTED ( 'table' ),
        'table'[plant] = SELECTEDVALUE ( 'table'[plant] )
            && YEAR ( 'table'[date] )
                = YEAR ( SELECTEDVALUE ( 'table'[date] ) ) - 1
            && MONTH ( 'table'[date] ) = MONTH ( SELECTEDVALUE ( 'table'[date] ) )
    )
)

 

Best Regards,

Jay 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @Anonymous ,

 

Use a single slicer and create two measures like below:

current_year_month =
CALCULATE (
    COUNT ( 'table'[value] ),
    FILTER (
        ALLSELECTED ( 'table' ),
        'table'[plant] = SELECTEDVALUE ( 'table'[plant] )
            && YEAR ( 'table'[date] ) = YEAR ( SELECTEDVALUE ( 'table'[date] ) )
            && MONTH ( 'table'[date] ) = MONTH ( SELECTEDVALUE ( 'table'[date] ) )
    )
)

Last_year_month =
CALCULATE (
    COUNT ( 'table'[value] ),
    FILTER (
        ALLSELECTED ( 'table' ),
        'table'[plant] = SELECTEDVALUE ( 'table'[plant] )
            && YEAR ( 'table'[date] )
                = YEAR ( SELECTEDVALUE ( 'table'[date] ) ) - 1
            && MONTH ( 'table'[date] ) = MONTH ( SELECTEDVALUE ( 'table'[date] ) )
    )
)

 

Best Regards,

Jay 

tamerj1
Super User
Super User

Hi @Anonymous 

try with two slicers, one for the year and one for the month and avoid using hierarchy slicer 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 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.