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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
heidibb
Helper IV
Helper IV

Line chart not recognizing legend field

Hello,

I am simply trying to plot a line chart with a rate over time, and then put an "ethnicity" field on the legend.

My rate is a calculated field, which should not matter, so I'm not sure why I'm having issues here. Other than the rate being a calculation, I can't think of why this might be happening.

The output is just showing the overal total as one line vs. splitting into many lines per ethnicity.

Any idea what might be happening behind the scenes?

 

Capture.PNG

7 REPLIES 7
v-lid-msft
Community Support
Community Support

Hi @heidibb ,

 

How about the result after you follow the suggestions mentioned in my original post?Could you please provide more details about it If it doesn't meet your requirement?


Best regards,

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
amitchandak
Super User
Super User

@heidibb , I doubt something wrong with your calculation you join with ethnicity, it seems like all lines are overlapping

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Yes, the ethnicities are overlapping because it's only plotting the overall total vs. splitting by ethnicity, which is what I can't understand.

If I take the "AllSelected" out of the calculation, the legend now works as expected, but my rate is not accurate. 

I would like to undersstand why the AllSelected part of this calculation is causing issues in the chart.

 

Hi @heidibb ,

 

Could you please try to use allselect on single column instead entire table, such as following:

 

Rolling Count - Census Retention GR =
VAR __currRow =
    MAX ( Main[DegreeLevelCohortTermAxis] )
VAR __startRow = __currRow - 4
RETURN
    CALCULATE (
        SUM ( Main[b_Year2Retention] ),
        ALLSELECTED ( 'Main'[DegreeLevelCohortTermAxis] ),
        Main[AcademicLevelCode] = "GR",
        'Main'[DegreeLevelCohortTermAxis] >= __startRow,
        'Main'[DegreeLevelCohortTermAxis] <= __currRow
    )

 

Rolling Count - Census Retention UR =
VAR __currRow =
    MAX ( Main[DegreeLevelCohortTermAxis] )
VAR __startRow = __currRow - 4
RETURN
    CALCULATE (
        SUM ( Main[b_Year2Retention] ),
        ALLSELECTED ( 'Main'[DegreeLevelCohortTermAxis] ),
        Main[AcademicLevelCode] = "UR",
        'Main'[DegreeLevelCohortTermAxis] >= __startRow,
        'Main'[DegreeLevelCohortTermAxis] <= __currRow
    )

 

When use Allselected(Main), it will ignore the Ethnicity Column.


Best regards,

 

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Pragati11
Super User
Super User

Hi @heidibb ,

 

I tried a line chart at my end and I get the legend with multiple lines.

line.png

Can you check in data, if you are using the right column as legend?

 

If this helps and resolves the issue, appreciate a Kudos and mark it as a Solution! 🙂

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

Yes, i'm pulling in the correct fields.

 

Here's what I've tried:
1. If I plot a straight student count (no claculation), the legend works fine
2. If I plot a simple calculation like sum(retention)/sum(studentcount), the legend works fine
3. If I plot the top Graduate calculated field as shown below, I get the single line only. So -- I think the issue is stemming from the graduate/undergraduate calculations, but I can't figure out why.
 
For reference, my calculated field consists of these steps:

For my graduate terms:

Rolling Count - Census Retention GR = 
VAR __currRow = max (Main[DegreeLevelCohortTermAxis])
VAR __startRow = __currRow - 4
RETURN
CALCULATE (sum(Main[b_Year2Retention]), ALLSELECTED(Main), Main[AcademicLevelCode] = "GR",
'Main'[DegreeLevelCohortTermAxis] >= __startRow , 'Main'[DegreeLevelCohortTermAxis] <= __currRow)

For my undergraduate terms:

Rolling Count - Census Retention UG = 
VAR __currRow = max (Main[DegreeLevelCohortTermAxis])
VAR __startRow = __currRow - 5
RETURN
CALCULATE (sum(Main[b_Year2Retention]), ALLSELECTED(Main), Main[AcademicLevelCode] = "UG",
'Main'[DegreeLevelCohortTermAxis] >= __startRow , 'Main'[DegreeLevelCohortTermAxis] <= __currRow)
Final calculation pulling them together:
% Census Retention = 
CALCULATE(SWITCH(SELECTEDVALUE(Main[AcademicLevelCode]), "UG", [Rolling Count - Census Retention UG], "GR", [Rolling Count - Census Retention GR])/

SWITCH(SELECTEDVALUE(Main[AcademicLevelCode]), "UG", [Rolling Count - Student Count UG], "GR", [Rolling Count - Student Count GR]))
 

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.

Top Solution Authors