cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
X19203659
Frequent Visitor

Dax: Date slicer showing 1 Pie chart with filtered data and 2nd chart showing the previous year data

Hi Team,

I will need help to do something very simple with dax function (I think).

 

The below screenshot shows a pie chart filtered by the slicer.

Now, i would like to add a second pie chart showing the data from the year 2022(previous year).

In order to work, the selection of the year need to be dynamic and based on the selected value by the slicer.
To complete this task, I have either the date with the number fomat (2023) or date format (01-01-2023 -- always firts day of the year). 

X19203659_0-1685653762454.png

 

Many thanks in advance for your support.

 

1 ACCEPTED SOLUTION
v-tangjie-msft
Community Support
Community Support

Hi @X19203659 ,

 

According to your description, here are my steps you can follow as a solution.

(1) This is my test data. 

vtangjiemsft_0-1686018217368.png

(2) We can create a measure. 

Last year = COUNTROWS(FILTER(ALL('Table'),YEAR('Table'[Date])=SELECTEDVALUE('Table'[Date].[Year])-1 && 'Table'[diff]=MAX('Table'[diff])))

(3)We can create a slicer.

vtangjiemsft_1-1686018331153.png

(4) Then the result is as follows.

vtangjiemsft_2-1686018394690.pngvtangjiemsft_3-1686018416117.png

 

 

 

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

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

2 REPLIES 2
v-tangjie-msft
Community Support
Community Support

Hi @X19203659 ,

 

According to your description, here are my steps you can follow as a solution.

(1) This is my test data. 

vtangjiemsft_0-1686018217368.png

(2) We can create a measure. 

Last year = COUNTROWS(FILTER(ALL('Table'),YEAR('Table'[Date])=SELECTEDVALUE('Table'[Date].[Year])-1 && 'Table'[diff]=MAX('Table'[diff])))

(3)We can create a slicer.

vtangjiemsft_1-1686018331153.png

(4) Then the result is as follows.

vtangjiemsft_2-1686018394690.pngvtangjiemsft_3-1686018416117.png

 

 

 

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

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

amitchandak
Super User
Super User

@X19203659 , you need one/both slicers on independent date table

Power BI How to use/compare two Date/Period slicers: https://youtu.be/WSeZr_-MiTg

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors