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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
NickProp28
Post Partisan
Post Partisan

Count and sum for specific column then compare between years

Dear experts,

 

Good day. I new to Power BI, and would like get some help from you guys.

In short,here is my data.

 

Date                Month    Country   Department

9/6/2019JuneChennaiIT
9/6/2019JuneChennaiIT
9/6/2019JuneUSAIT
9/6/2020JuneUSAHR
10/6/2020JuneUSAHR
10/7/2019JulyChennaiIT
11/7/2019JulyChennaiHR
11/7/2020JulyUSAHR
11/7/2020JulyUSAIT

 

And here my expected outcome .Count and sum the department, and i would like to compare between two years. (Will add country in my slicer, but if not the outcome will like this)

 20192020
June32
July22


My sincerely appreciate for the help.

3 ACCEPTED SOLUTIONS
v-lionel-msft
Community Support
Community Support

Hi @NickProp28 ,

 

Please refer to my .pbix file.

fff8.PNGfff9.PNG

 

Best regards,
Lionel Chen

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

Hi @NickProp28 ,

 

I think it would be very strange for you to add measure 2 to the same matrix, because the column value of your matrix are years.

So I created another table visual.

fff14.PNG

 

Are you sure what you want is the following visual effect?

fff15.PNG

 

Best regards,
Lionel Chen

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

Hi @NickProp28 ,

 

Please use the formula.

Measure 2 = 
VAR x = 
CALCULATE(
    COUNT(Sheet4[Department]),
    FILTER(
       ALLSELECTED( Sheet4),
        Sheet4[Month] = MAX(Sheet4[Month] ) && Sheet4[Year] = 2019
    )
)
VAR y = 
CALCULATE(
    COUNT(Sheet4[Department]),
    FILTER(
        ALLSELECTED(Sheet4),
        Sheet4[Month] = MAX(Sheet4[Month] ) && Sheet4[Year] = 2020
    )
)
RETURN
DIVIDE(
    y, x, BLANK()
)

fff16.PNG 

 

Best regards,
Lionel Chen

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

7 REPLIES 7
v-lionel-msft
Community Support
Community Support

Hi @NickProp28 ,

 

Please refer to my .pbix file.

fff8.PNGfff9.PNG

 

Best regards,
Lionel Chen

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

 

 

Dear @v-lionel-msft ,

Based on this question, can you help me out on divide this two years (Year 2020/year 2019)? I want get the Variance.
Thanks so much if you could help. 

Hi @NickProp28 ,

 

You can do like this.

fff13.PNG

fff12.PNG

 

Measure 2 = 
VAR x = 
CALCULATE(
    COUNT(Sheet4[Department]),
    FILTER(
        Sheet4,
        Sheet4[Month] = MAX(Sheet4[Month] ) && Sheet4[Year] = 2019
    )
)
VAR y = 
CALCULATE(
    COUNT(Sheet4[Department]),
    FILTER(
        Sheet4,
        Sheet4[Month] = MAX(Sheet4[Month] ) && Sheet4[Year] = 2020
    )
)
RETURN
DIVIDE(
    y, x, BLANK()
)

 

Best regards,
Lionel Chen

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

 

Dear @v-lionel-msft ,

 

This is the solution I looking for, but i tried the code and seems does not work well for me. Would you mind share the .pbix to me?
I very much appreciate your support.
Screenshot_1.png

Hi @NickProp28 ,

 

I think it would be very strange for you to add measure 2 to the same matrix, because the column value of your matrix are years.

So I created another table visual.

fff14.PNG

 

Are you sure what you want is the following visual effect?

fff15.PNG

 

Best regards,
Lionel Chen

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

Dear @v-lionel-msft ,

I get what you mean. Yup, I get the outcome.
I'm sorry for asking, isit there have any possible way to make all into one table without separate it into two?

Year2019Year2020Variance
   


Best regards and thanks.

Hi @NickProp28 ,

 

Please use the formula.

Measure 2 = 
VAR x = 
CALCULATE(
    COUNT(Sheet4[Department]),
    FILTER(
       ALLSELECTED( Sheet4),
        Sheet4[Month] = MAX(Sheet4[Month] ) && Sheet4[Year] = 2019
    )
)
VAR y = 
CALCULATE(
    COUNT(Sheet4[Department]),
    FILTER(
        ALLSELECTED(Sheet4),
        Sheet4[Month] = MAX(Sheet4[Month] ) && Sheet4[Year] = 2020
    )
)
RETURN
DIVIDE(
    y, x, BLANK()
)

fff16.PNG 

 

Best regards,
Lionel Chen

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

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.