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 ]

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 ]

Proud to be a Super User!    