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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
mogunase1
Helper III
Helper III

Current year vs last year

Hi ,

 

I have dataset like, want to calculate count where (Pass = "N")

MonthYearpass
Jan2019Y
Jan2019Y
Jan2019N
Jan2019N
Feb2019Y
Feb2019N
Feb2019Y
Feb2019N
Feb2019N
Jan2020N
Jan2020N
Jan2020Y
Feb2020N
Feb2020N
Mar2020N
Mar2020Y
Mar2020Y

 

1. I want month wise current year (2021) and last year trend (2020) chart trend.

2.latest year in table (2020) and last to that table (2019) trend.

 

2 bar chart  i need with type of requirement.

DAX is DPV = calculate(count(pass),pass = "N") - Here i need to mention another cpndition with respect to above 2 condition.

 

Thanks,

Mohan

 

@Jihwan_Kim

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@mogunase1 , Plot month on-axis year on legend and use the given one as a measure.

 

Create a column like this in you table and date table and select this year and last year and save

 

Year Type = Switch( True(),
year([Date])= year(Today()),"This Year" ,
year([Date])= year(Today())-1,"Last Year" ,
Format([Date],"YYYY")
)

 

View solution in original post

3 REPLIES 3
Jihwan_Kim
Super User
Super User

Hi, @mogunase1 

Please correct me if I wrongly understood your question.

Please check the below picture and the sample pbix file's link down below.

All measures are in the sample pbix file.

 

Picture1.png

 

 
Count Y =
CALCULATE( COUNTROWS(data), data[pass] = "Y")+0
 
Count N =
CALCULATE( COUNTROWS(data), data[pass] = "N")+0
 
 
 
 

Hi, My name is Jihwan Kim.


If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.


Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


amitchandak
Super User
Super User

@mogunase1 , Plot month on-axis year on legend and use the given one as a measure.

 

Create a column like this in you table and date table and select this year and last year and save

 

Year Type = Switch( True(),
year([Date])= year(Today()),"This Year" ,
year([Date])= year(Today())-1,"Last Year" ,
Format([Date],"YYYY")
)

 

In this case,

I have data for 2019,2020 and no data for 2021.

But i  always need current year (2021) and Previous year (2020) data alone, even though if there is no data in 2021 it need to show the chart with 0 value for 2021.

In this case what we can do?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.