cancel
Showing results for
Did you mean:
New Member

## difference of count

Hi All,

i have a huge dataset with two labels 2019 and 2020, i would like to get the difference of count ie- for the below example - output = 3-2= 1 so if i use Card visual, i should be getting 1

class

2019

2019

2019

2020

2020

TIA

2 ACCEPTED SOLUTIONS
Super User IV

@ekta , better to have a separate Year table (Say Date)

This Year = CALCULATE(sum('order'[Qty]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])))
Last Year = CALCULATE(sum('order'[Qty]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])-1))

diff = [This Year]-[Last Year ]

or

This Year = CALCULATE(sum('order'[Qty]),filter(ALL('Date'),'Date'[Year]=2020))
Last Year = CALCULATE(sum('order'[Qty]),filter(ALL('Date'),'Date'[Year]=2019))

diff = [This Year]-[Last Year ]

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

Responsive Resident

Hello @ekta ,
Try this measure
Difference =
VAR Total2019 =
CALCULATE ( COUNT ( 'Year Table'[Year] ), 'Year Table'[Year] = 2019 )
VAR Total2020 =
CALCULATE ( COUNT ( 'Year Table'[Year] ), 'Year Table'[Year] = 2020 )
RETURN
Total2019 - Total2020

2 REPLIES 2
Responsive Resident

Hello @ekta ,
Try this measure
Difference =
VAR Total2019 =
CALCULATE ( COUNT ( 'Year Table'[Year] ), 'Year Table'[Year] = 2019 )
VAR Total2020 =
CALCULATE ( COUNT ( 'Year Table'[Year] ), 'Year Table'[Year] = 2020 )
RETURN
Total2019 - Total2020

Super User IV

@ekta , better to have a separate Year table (Say Date)

This Year = CALCULATE(sum('order'[Qty]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])))
Last Year = CALCULATE(sum('order'[Qty]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])-1))

diff = [This Year]-[Last Year ]

or

This Year = CALCULATE(sum('order'[Qty]),filter(ALL('Date'),'Date'[Year]=2020))
Last Year = CALCULATE(sum('order'[Qty]),filter(ALL('Date'),'Date'[Year]=2019))

diff = [This Year]-[Last Year ]

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

Announcements

#### Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group!

#### Claim Your Badge & Digital Swag!

Check out how to claim yours today!

#### Are You Ready?

Test your skills now with the Cloud Skills Challenge.

Top Solution Authors
Top Kudoed Authors