Forum Discussion
Help with Multiple Filters from User Selection Slicers
Hi,
I have a calendar table which has columns Year and Period that I'm using as slicers:
I'm using these to filter out data from 6 data tables; these 6 tables also contain the columns Year and Period. When I previously had data for Year 19-20 only the figures were calculated correctly but when I've now added data for Year 20-21 I'm getting a summation of Years 19-20 and 20-21 instead of just the Year and Period selected.
I have the following data as an example:
The slicers are as follows:
When I select the Year and Period then the calculations are made based on this user selection. I have the following KPIs that I'm calculating:
A bit tricky, but a disconnected table trick and this measure later and I think I got it. PBIX is attached:
SIP Actual Line Chart = VAR __Year = MAX('SIP_Activities'[Year]) VAR __Period = MAX('SIP_Activities'[Period]) + 0 VAR __LinePeriod = MAX('Periods'[Period]) + 0 VAR __Table = FILTER(ALL(SIP_Activities),[Year] = __Year && [Period]+0 <= __Period) VAR __Table1 = FILTER(__Table,[Period]+0 = __LinePeriod) RETURN SUMX(__Table1,[Actual-LD]) + SUMX(__Table1,[Late Delivery])
23 Replies
- Greg_Deckler
Community Champion
If you could post the data as text could potentially recreate, otherwise nice job of following the principles in this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490
However, I am thinking what you need to do is create two a new column in each of your tables that concatenates your year and period. Then create a new table Table = DISTINCT('Table1or2'[YearPeriod]).
Then use that in your slicer? Many to many relationships are generally bad.
- PowerBI-Newbie
Helper IV
Hi Greg_Deckler ,
Thank you for your quick response.
Here's the data as text:
Calendar:
Year Period 19-20 1 19-20 2 19-20 3 19-20 4 19-20 5 19-20 6 19-20 7 19-20 8 19-20 9 19-20 10 19-20 11 19-20 12 19-20 13 20-21 1 20-21 2 20-21 3 20-21 4 20-21 5 20-21 6 20-21 7 20-21 8 20-21 9 20-21 10 20-21 11 20-21 12 20-21 13 Data:
Year Period Planned Actual 19-20 1 9 9 19-20 2 15 15 19-20 3 16 17 19-20 4 14 15 19-20 5 12 10 19-20 6 13 13 19-20 7 10 13 19-20 8 11 13 19-20 9 9 9 19-20 10 12 13 19-20 11 9 9 19-20 12 10 12 19-20 13 9 3 20-21 1 1 1 20-21 2 2 2 20-21 3 3 3 20-21 4 4 4 20-21 5 5 5 20-21 6 6 6 20-21 7 7 7 20-21 8 8 8 20-21 9 9 9 20-21 10 10 10 20-21 11 11 11 20-21 12 12 12 20-21 13 13 13 I thought of your suggestion but the end-user needs the slicer to look like the screenshot from my original post plus I also have YTD calculations so not sure if that would have an impact. Excuse my silly questions but why does it work well for Year 19-20 but not for 20-21? For some reason I can't choose anything else other than many to many relationship. I also had both directional before but changing it to single direction doesn't seem to do anything.
- Greg_Deckler
Community Champion
Will have to recreate to know. Give me some time. You could still have the slicer look like that, you would just create columns in your new table that split the year and period back out.
- amitchandak
Super User
PowerBI-Newbie , In case you have date, prefer using time intelligence
YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD((Table[Date]),"12/31")) This Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD((ENDOFYEAR(Table[Date])),"12/31")) Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd(Table[Date],-1,Year),"12/31")) Last YTD complete Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(ENDOFYEAR(dateadd(Table[Date],-1,Year)),"12/31")) Last to last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd(Table[Date],-2,Year),"12/31")) Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd(Table[Date],-1,Year))To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/- PowerBI-Newbie
Helper IV
Hi amitchandak ,
Thank you for your response.
Unfortunately we don't use date for this particular dashboard, it's only Fiscal Year and Period as per my data.