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
Nerf_Herder
Frequent Visitor

Card Visual (DAX) with two Slicers

Hi Everyone,

 

I'm after some help with slicers. 

 

I have two slicers: 'Customer' & 'Subscription'.

I have a Card visual which displays the Customer name(s) selected in the Customer slicer. What I want to be able to do is have the Customer name showing when only their Subscription is selected, without selecting from the Customer Slicer (one sub per customer).

 

I have the following DAX for selecting the customers:

Customers =

IF(
    NOT(ISFILTERED('Table'[CustomerName])),
    "All Customers",
    IF(
        HASONEVALUE('Table'[CustomerName]),
        VALUES('Table'[CustomerName]),
        CONCATENATEX(
            VALUES('Table'[CustomerName]),
            'Table'[CustomerName],
            ", "
        )
    )
)
Nerf_Herder_1-1682688574530.png

I'm wonderin if the DAX can be amended to accomodate what I'm wanting to do?

I've tried changing the 'VALUES' to 'ALLSELECTED' but it doesn't work.

 

Unfortunately I can't provide a pbix file.

 

As always, your help is most appreciated and thank you in advance.

 

Cheers

Ian.

1 ACCEPTED SOLUTION

@Nerf_Herder 

If I understood right, You need sth like this using SWITCH to handle different cases:

 

 

SWITCH (
    TRUE (),
    NOT ( ISFILTERED ( 'Table'[Subscription] ) )
        && NOT ( ISFILTERED ( 'Table'[CustomerName] ) ), "All Customers",
    HASONEVALUE ( 'Table'[Subscription] )
        && NOT ( ISFILTERED ( 'Table'[CustomerName] ) ), VALUES ( 'Table'[CustomerName] ),
    HASONEVALUE ( 'Table'[CustomerName] )
        && NOT ( ISFILTERED ( 'Table'[Subscription] ) ), VALUES ( 'Table'[CustomerName] ),
    ISFILTERED ( 'Table'[Subscription] )
        && HASONEVALUE ( 'Table'[Subscription] ) = FALSE (), CONCATENATEX ( VALUES ( 'Table'[CustomerName] ), 'Table'[CustomerName], ", " ),
    ISFILTERED ( 'Table'[CustomerName] )
        && HASONEVALUE ( 'Table'[CustomerName] ) = FALSE (), CONCATENATEX ( VALUES ( 'Table'[CustomerName] ), 'Table'[CustomerName], ", " ),
    CONCATENATEX ( VALUES ( 'Table'[CustomerName] ), 'Table'[CustomerName], ", " )
)

 

 

Now the logic is clear. Based on your need you can edit it easily.

 

It helped? Mark it as an accepted solution.
Regards,
Loran

View solution in original post

4 REPLIES 4
MohammadLoran25
Super User
Super User

Hi @Nerf_Herder ,

Both name and subscription are in the same table?

You can get by a little bit change as below:

Customers =
IF (
    NOT ( ISFILTERED ( 'Table'[Subscription] ) ),
    "All Customers",
    IF (
        HASONEVALUE ( 'Table'[Subscription] ),
        VALUES ( 'Table'[CustomerName] ),
        CONCATENATEX ( VALUES ( 'Table'[CustomerName] ), 'Table'[CustomerName], ", " )
    )
)

 

It helped? Mark it as an accepted solution.
Regards,
Loran

Hi @MohammadLoran25,

 

Thank you for your help here, that worked for the Subscription slicer. The issue is I still need the Customer name slicer to work on the card. Do you know if that can be done?

 

To answer your question, yes the customer name and subscription is all in one table.

 

Cheers

Ian.

@Nerf_Herder 

If I understood right, You need sth like this using SWITCH to handle different cases:

 

 

SWITCH (
    TRUE (),
    NOT ( ISFILTERED ( 'Table'[Subscription] ) )
        && NOT ( ISFILTERED ( 'Table'[CustomerName] ) ), "All Customers",
    HASONEVALUE ( 'Table'[Subscription] )
        && NOT ( ISFILTERED ( 'Table'[CustomerName] ) ), VALUES ( 'Table'[CustomerName] ),
    HASONEVALUE ( 'Table'[CustomerName] )
        && NOT ( ISFILTERED ( 'Table'[Subscription] ) ), VALUES ( 'Table'[CustomerName] ),
    ISFILTERED ( 'Table'[Subscription] )
        && HASONEVALUE ( 'Table'[Subscription] ) = FALSE (), CONCATENATEX ( VALUES ( 'Table'[CustomerName] ), 'Table'[CustomerName], ", " ),
    ISFILTERED ( 'Table'[CustomerName] )
        && HASONEVALUE ( 'Table'[CustomerName] ) = FALSE (), CONCATENATEX ( VALUES ( 'Table'[CustomerName] ), 'Table'[CustomerName], ", " ),
    CONCATENATEX ( VALUES ( 'Table'[CustomerName] ), 'Table'[CustomerName], ", " )
)

 

 

Now the logic is clear. Based on your need you can edit it easily.

 

It helped? Mark it as an accepted solution.
Regards,
Loran

@MohammadLoran25,

 

Wow! Honestly that's amazing! I can't thank you enough. That worked exactly as I want it to!

 

Thank you!!

Ian.

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.