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
PowerBI-Newbie
Helper III
Helper III

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:

Power BI Report-Dashboard-Calendar Data.PNG

 

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:

Power BI Report-Dashboard-SIP Data.PNG

 

The slicers are as follows:

Power BI Report-Dashboard-Slicers.PNG

 

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:

Period calculation measure:
SIP Actual = (sum(SIP_Activities[Actual-LD]) + sum(SIP_Activities[Late Delivery]))
 
YTD calculation measure:
SIP Actual (YTD) =
CALCULATE (
SUMX('SIP_Activities', [SIP Actual]),
FILTER (
ALLEXCEPT ( 'Calendar_Table', 'Calendar_Table'[Year]),
'Calendar_Table'[Period] <= MAX ( 'Calendar_Table'[Period] )
)
)
 
I had many-many relationship and single direction (calendar table filtering the respective table) which worked fine until I had data for the new fiscal year. So now when I select Year 20-21 and Period 1 I'm getting 10 for Planned instead of 1, and consequently my YTD figure for the new financial year should 1 for Planned instead of 10.
Any help is greatly appreciated. 
1 ACCEPTED SOLUTION

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])

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

23 REPLIES 23

Thank you very much @Greg_Deckler , that did the trick.

 

If I want to apply this to other tables and columns, do I need to change anything such as the variable names?

The variable names can stay the same, the overall name of the measure needs to be unique

 

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])

 

Red is the measure name, has to be unique. Green are table names that you would update. Blue is column names that you would update. You could leave the measure names the same although the names may not make total sense depending on your tables/periods, etc. that you are switching things to. 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Thank you very much @Greg_Deckler , I really appreciate it.

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.