Forum Discussion

Rees's avatar
Rees
Frequent Visitor
6 years ago

Stacked Column Chart Linked to Card

Hello, I am pretty new to PowerBI. I have a dashboard (not created by me) that has a stacked column chart showing total user count per month for the past 13 months. There is also a card showing the total user count for one particular user type (the stacked chart includes all user types).

 

When I click on a single column in the stacked chart, the card shows the counts for that user type. This is good.

When I click off of specific column (so that the entire stacked chart is 'focused', the card shows counts for that user type,  across the entire 13 month span. This is good. 

 

So, there is a linkage there.  I would like to make the title dynamic. So, across all 13 months shown (Aug/2018 to Aug/2019 for example), I would like to make the title "9/2018-9/2019 Type A UCount" for the Card. If I click on 4/2019, I would like the card title  to be "4/2019 Type A UCount".

 

I have successfully made dynamic titles using DAX expresssions (I think that is what they are called). I have a successfull DAX expression changing the title to the specific month/year that is clicked on (in the stacked chart). However, I cannot seem to determine when all columns are focused. 

I don't know how to do it based on the specific bar clicked on in the Stacked Column Chart.  Is there a way? Seems like there should be. I mean, I've used various reporting tools for quite some time, and dynamic column labels are pretty easy to do.

5 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    HI Rees ,

    Actually, the highlight effect is similar to normal filter, you can use dax functions(allselected/values, min/max) to get current selection.

    Sample title measure:

    title measure =
    IF (
        COUNTROWS ( VALUES ( 'Table'[Date] ) ) > 1,
        MIN ( 'Table'[Date] ) & " - "
            & MAX ( 'Table'[Date] ) & " sales",
        MIN ( 'Table'[Date] ) & " sales"
    )
    

    Regards,

    Xiaoxin Sheng

    • Rees's avatar
      Rees
      Frequent Visitor

      Hi, I must be doing something differently than you. Your example clearly shows this working. I have the following DAX expression defined:

      MAUcardTitle = IF ( COUNTROWS ( VALUES ( 'MAU Rollups'[YearMonthDisplay] ) ) > 1, MIN ( 'MAU Rollups'[YearMonthDisplay] ) & " - " & MAX ( 'MAU Rollups'[YearMonthDisplay] ) , MIN ( 'MAU Rollups'[YearMonthDisplay] ) )
       
      Also, if I add COUNTROWS ( VALUES ( 'MAU Rollups'[YearMonthDisplay] ) ) to the TRUE side if the IF statement, I see 13, always. Even when one column is selected. 
       
      I am always seeing 2018-08 - 2019-08. Even when I click on a single month (any month in the stacked chart). 
      The value displayed on the card does change appropriately as I click on and off of different columns in the stacked chart. It's just the title that I cannot yet change dynamically. It's strange because I can clearly see your example is working, and it is using COUNTROWS
      • Anonymous's avatar
        Anonymous
        Not applicable

        HI Rees ,

        I found your date values are stored in text type, some of DAX functions can't work properly with text values. (min/max works on numeric or date type)
        Please modify your filed type to 'date', then my measure formula can extract corresponding values.

        Regards,

        Xiaoxin Sheng

    • Rees's avatar
      Rees
      Frequent Visitor

      I don't know if you were able to see my results on this suggestion. I can see in your example that it is working. Unfortunately, in mine it is not. I believe I recreated everything you did. I believe the cause is that the Return from COUNTROWS is always the total number of columns shown in the Stacked Column Chart. So, even when highlighting a single chart by clicking on it, the data changes, but the title stays the same because the result from COUNTROWS is always 13.

      Do you have any idea why that might be?