cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ekta
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
amitchandak
Super User IV
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!

View solution in original post

TarunSharma
Responsive Resident
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
Capture.PNG

View solution in original post

2 REPLIES 2
TarunSharma
Responsive Resident
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
Capture.PNG

View solution in original post

amitchandak
Super User IV
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!

View solution in original post

Helpful resources

Announcements
PBI User Groups

Welcome to the User Group Public Preview

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

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are You Ready?

Test your skills now with the Cloud Skills Challenge.

Top Solution Authors