Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi,
I'm experiencing a problem when trying to use two slicers to select data for my visualization - here's a summary:
Problem Summary
Objective: I want to create a measure in Power BI that sums the hours for staff members based on two conditions:
• The hours for the selected Team, regardless of the Delivery Portfolio, plus
• The hours for the Team = "Team Two" where the Delivery Portfolio matches the selected value.
Current Setup:
• I have a matrix visualization that shows 'Export'[Staff Name] in the Rows, Weeks in the Columns, and the sum of 'Export'[Hours] in Values.
• I have a slicer to select the Team ('Export'[Team]).
• I also have a slicer to select the Delivery Portfolio ('Export'[Delivery Portfolio]).
Challenges:
• Ensuring that the measure correctly sums the hours for the selected Team without being affected by the Delivery Portfolio.
• Including the hours for "Team Two" where the Delivery Portfolio matches the selected value, without duplicating totals or missing data.
Can anyone please advise how I should approach this?
Thanks!
I hope this below expression solves your requirements
Var __SelectedTeam = Selectedvalue(Export[Team])
Var __SelectedDeliveryPosition = Selectedvalue(Export[Delivery Postion])
Var __measure1 = calculate(sum(Export[Hours]), REMOVEFILTERS(Export[Delivery Postion]))
Var __measure2 = Calculate(sum(Export[Hours]), Export[Team] = "Team Two")
Return __measure1 + __measure2
For further assitance, please share the sample data and expected output
Need a Power BI Consultation? Hire me on Upwork
Connect on LinkedIn
|
Hi and thanks for your response. I’m not familiar with the use of variables, but I have translated your code to the following:
CombinedHours =
VAR __SelectedTeam = SELECTEDVALUE('Export'[Team])
VAR __SelectedDeliveryPortfolio = SELECTEDVALUE('Export'[Delivery Portfolio])
VAR __measure1 = CALCULATE(SUM('Export'[Hours]), REMOVEFILTERS('Export'[Delivery Portfolio]))
VAR __measure2 = CALCULATE(SUM('Export'[Hours]), 'Export'[Team] = "Team Two" && 'Export'[Delivery Portfolio] = __SelectedDeliveryPortfolio)
RETURN __measure1 + __measure2
What I’m trying to achieve is:
Can you please advise how to amend the DAX formula above to achieve this? And further advice would be greatly appreciated.
Thanks!
User | Count |
---|---|
22 | |
11 | |
8 | |
6 | |
6 |
User | Count |
---|---|
25 | |
13 | |
11 | |
9 | |
6 |