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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
danialsj
Frequent Visitor

Line Chart: Show total average as default. Show specific categories on filter selection

I have a line chart that shows the average score of 4 regions over the last 6 months.

 

I want the line chart to show the total average of all 4 regions in one line when there is no filter selected.

 

When Region 1 is selected, the line chart should show only Region 1's average line. When both Region 1 and 2 are selected, the line chart should show both Region 1 and 2's average in two lines.

 

Is this possible to do?

 

Thanks.

 

 

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @danialsj ,

 

Being a line chart you need to create 5 measures (one for each region and one for the average):

Region 1 =
IF (
    DISTINCTCOUNT ( 'Table'[Region] )
        = CALCULATE ( DISTINCTCOUNT ( 'Table'[Region] ); ALL ( 'Table'[Region] ) );
    BLANK ();
    IF (
        CONTAINS ( 'Table'; 'Table'[Region]; 1 );
        CALCULATE ( AVERAGE ( 'Table'[Value] ); 'Table'[Region] = 1 )
    )
)

Region 2 =
IF (
    DISTINCTCOUNT ( 'Table'[Region] )
        = CALCULATE ( DISTINCTCOUNT ( 'Table'[Region] ); ALL ( 'Table'[Region] ) );
    BLANK ();
    IF (
        CONTAINS ( 'Table'; 'Table'[Region]; 2);
        CALCULATE ( AVERAGE ( 'Table'[Value] ); 'Table'[Region] = 2 )
    )
)

Region 3 =
IF (
    DISTINCTCOUNT ( 'Table'[Region] )
        = CALCULATE ( DISTINCTCOUNT ( 'Table'[Region] ); ALL ( 'Table'[Region] ) );
    BLANK ();
    IF (
        CONTAINS ( 'Table'; 'Table'[Region]; 3 );
        CALCULATE ( AVERAGE ( 'Table'[Value] ); 'Table'[Region] = 3 )
    )
)

Region 4 =
IF (
    DISTINCTCOUNT ( 'Table'[Region] )
        = CALCULATE ( DISTINCTCOUNT ( 'Table'[Region] ); ALL ( 'Table'[Region] ) );
    BLANK ();
    IF (
        CONTAINS ( 'Table'; 'Table'[Region]; 4 );
        CALCULATE ( AVERAGE ( 'Table'[Value] ); 'Table'[Region] = 4 )
    )
)

Region All =
IF (
    DISTINCTCOUNT ( 'Table'[Region] )
        = CALCULATE ( DISTINCTCOUNT ( 'Table'[Region] ); ALL ( 'Table'[Region] ) );
    CALCULATE ( AVERAGE ( 'Table'[Value] ) );
    BLANK ()
)

 

Then just place the measures in the chart.

 

Regards,

MFelix

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

1 REPLY 1
MFelix
Super User
Super User

Hi @danialsj ,

 

Being a line chart you need to create 5 measures (one for each region and one for the average):

Region 1 =
IF (
    DISTINCTCOUNT ( 'Table'[Region] )
        = CALCULATE ( DISTINCTCOUNT ( 'Table'[Region] ); ALL ( 'Table'[Region] ) );
    BLANK ();
    IF (
        CONTAINS ( 'Table'; 'Table'[Region]; 1 );
        CALCULATE ( AVERAGE ( 'Table'[Value] ); 'Table'[Region] = 1 )
    )
)

Region 2 =
IF (
    DISTINCTCOUNT ( 'Table'[Region] )
        = CALCULATE ( DISTINCTCOUNT ( 'Table'[Region] ); ALL ( 'Table'[Region] ) );
    BLANK ();
    IF (
        CONTAINS ( 'Table'; 'Table'[Region]; 2);
        CALCULATE ( AVERAGE ( 'Table'[Value] ); 'Table'[Region] = 2 )
    )
)

Region 3 =
IF (
    DISTINCTCOUNT ( 'Table'[Region] )
        = CALCULATE ( DISTINCTCOUNT ( 'Table'[Region] ); ALL ( 'Table'[Region] ) );
    BLANK ();
    IF (
        CONTAINS ( 'Table'; 'Table'[Region]; 3 );
        CALCULATE ( AVERAGE ( 'Table'[Value] ); 'Table'[Region] = 3 )
    )
)

Region 4 =
IF (
    DISTINCTCOUNT ( 'Table'[Region] )
        = CALCULATE ( DISTINCTCOUNT ( 'Table'[Region] ); ALL ( 'Table'[Region] ) );
    BLANK ();
    IF (
        CONTAINS ( 'Table'; 'Table'[Region]; 4 );
        CALCULATE ( AVERAGE ( 'Table'[Value] ); 'Table'[Region] = 4 )
    )
)

Region All =
IF (
    DISTINCTCOUNT ( 'Table'[Region] )
        = CALCULATE ( DISTINCTCOUNT ( 'Table'[Region] ); ALL ( 'Table'[Region] ) );
    CALCULATE ( AVERAGE ( 'Table'[Value] ) );
    BLANK ()
)

 

Then just place the measures in the chart.

 

Regards,

MFelix

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors