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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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