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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.