Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
shwetadalal
Regular Visitor

Data values change after adding legend in chart

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 .

 

shwetadalal_1-1695130360721.png

 

shwetadalal_2-1695132435025.png

 

 

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.

 

 

1 REPLY 1
lbendlin
Super User
Super User

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?

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.