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.
I know this issue has already been addressed previously in https://community.fabric.microsoft.com/t5/Desktop/Data-changing-when-adding-legend/td-p/1973003 , but even after following the method given in its solution, I am not getting the correct result.
Below are the charts showing the distinct count of Number of Employees. When I add the legend 'Location Name" the values change. I understood that this occurs when the context of data changes and to address it I followed the solution mentioned addressed in the post above.
Here in the measure the number of employees displayed is the number of employees for the last month of each year. So for example for year 2023 the last month is August for which there is data, then in the chart you will see for year 2023 the number of employees = number of employees in August 2023. Similarly, if you drill down from year to quarter you will see that the last quarter for 2023 will have value for August 2023. Similarly, the calculation works for other years too.
But the issue is when I add "Location Name" legend, the numbers do not stay consistent. I followed the logic mentioned previously in other post I mentioned above to change the context but it doesn't work .
The PBIX file :
Number of Employees PBIX
Measure:
TestTotalEmp_Location =
VAR _active_Monthly =
CALCULATE (
DISTINCTCOUNT ( 'MonthlyEmployeeSurvey'[Please enter the Employee ID.] ),
FILTER (
'MonthlyEmployeeSurvey',
'MonthlyEmployeeSurvey'[TerminationCount] = 0
),
FILTER (
ALLSELECTED ( MonthlyEmployeeSurvey[Please enter the Employee ID.] ),
[Max_LocationAlias] = MAX ( MonthlyEmployeeSurvey[Location Name] )
)
)
RETURN
( _active_Monthly )
Max_LocationAlias =
CALCULATE (
MAXX (
ALLSELECTED ( MonthlyEmployeeSurvey ),
MonthlyEmployeeSurvey[Location Name]
),
GROUPBY (
'MonthlyEmployeeSurvey',
DateSlicer[Date],
MonthlyEmployeeSurvey[Please enter the Employee ID.]
)
)
Any help or suggestion is appreciated.
Thanks in advance.
In your chart you are asking for a distinct count. That's what you get. What is your expected outcome when you add the legend?
User | Count |
---|---|
22 | |
11 | |
8 | |
6 | |
6 |
User | Count |
---|---|
25 | |
12 | |
11 | |
8 | |
6 |