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
Mann
Resolver III
Resolver III

As per Slicer value measure should change in Line Graph

Hi All,

 

I have created a line chart where I am showing fives lines coming from five measures dragged to "Values" section with Axis having "Datetime" field.

Measure calculation is similar for all five with different filter context coming from a single column [Type] as shown:

Measure 1:= CALCULATE([Count],'Table1'[Type]="Type A")
Measure 2:= CALCULATE([Count],'Table1'[Type]="Type B")
Measure 3:= CALCULATE([Count],'Table1'[Type]="Type C")
Measure 4:= CALCULATE([Count],'Table1'[Type]="Type D")
Measure 5:= CALCULATE([Count],'Table1'[Type]="Type E")

Graph is showing five lines with respect to these five measure.

I also have a slicer on this column = [Type]

 

I want:

1) If I select any one value (Type A or Type B or Type C or Type D or Type E) from this [Type] slicer only for that type, line should come on chart and others should go away.

2) If I select any two or more than two values from slicer then only those lines should be there for which type values are selected from slicer.

 

I tried using SELECTEDVALUE but it doesn't give required results. As shown for new measure 1:

Measure 1 New = IF(CALCULATE(SELECTEDVALUE('Table1'[Type A])="Type A"),Measure 1,BLANK())

This works fine if I select slicer one by one but if I select any other slicer with slicer value = Type A then it fails.

 

Please advice.

Thanks

 

 

1 ACCEPTED SOLUTION

Thanks for checking in Ashish.

I could solve this using CONTAINS() DAX function instead of SELECTEDVALUE().

 

Here is the code. I have to replace these five old measure to these new ones to accomplish which I need.

Measure 1 New = 
VAR A =
    Measure 1
RETURN
    IF (
        CONTAINS (
            'Table1',
            'Table1'[Type A], "Type A"
        ),
        A,
        BLANK ()
    )

Thanks for the help!

 

 

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

Writing 5 measures should not be necessary.  To help further, i will need to see your PBI file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thanks for checking in Ashish.

I could solve this using CONTAINS() DAX function instead of SELECTEDVALUE().

 

Here is the code. I have to replace these five old measure to these new ones to accomplish which I need.

Measure 1 New = 
VAR A =
    Measure 1
RETURN
    IF (
        CONTAINS (
            'Table1',
            'Table1'[Type A], "Type A"
        ),
        A,
        BLANK ()
    )

Thanks for the help!

 

 

Hi,

Sorry but with such scanty information, i really cannot help.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

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.