Forum Discussion

tchan's avatar
tchan
Frequent Visitor
6 years ago
Solved

Switching tables in Multi-row cards

Hi all,

I am looking for a way to switch table in a multi-row cards graph

For instance in https://coronavirus.jhu.edu/map.html

In the bottom left graph (Confirmed Cases by Province/State/Dependency), when user clicks on the arrow, user can choose whether they want to view all confirmed cases by Country or by Provice.

 

 

Could you please let me know how can i achieve this in power bi?

 

Thanks a lot

3 Replies

    • tchan's avatar
      tchan
      Frequent Visitor

      Bookmark is the right solution for my problem. Thank you so much for your help!

  • littlemojopuppy's avatar
    littlemojopuppy
    Icon for Community Champion rankCommunity Champion

    First, cool presentation!  😁

    I accomplished something similar and I'll walk you through the process and provide code samples from my project.

    First create measures for each of the different ways you want to summarize.  For example...

     

    Active Enrollments = 
        CALCULATE(
            DISTINCTCOUNT(ProgramEnrollments[Id]),
            ISBLANK(ProgramEnrollments[Complete]) = TRUE(),
            ProgramEnrollments[EndDate] >= TODAY(),
            USERELATIONSHIP('Calendar'[Date], ProgramEnrollments[StartDate])
        )
    
    Complete Enrollments = 
        CALCULATE(
            DISTINCTCOUNT(ProgramEnrollments[Id]),
            ProgramEnrollments[Complete] = TRUE(),
            ProgramEnrollments[CompletionCode] = 1,
            USERELATIONSHIP('Calendar'[Date], ProgramEnrollments[CompleteDate])
        )
    
    And so on...

     

     

    You would provide measures to aggregate data by region, country, etc.

     

    Next you create a measure that will key on the SELECTEDVALUE from the slicer to choose which measure value to use.  Remember to provide a default in case someone hasn't selected a summarization (or make the slicer single select which forces one to be selected).

     

    Enrollment Count = 
        SWITCH(
            SELECTEDVALUE(ProgramEnrollments[ProgramEnrollmentStatus]),
            "Active", [Active Enrollments],
            "Expired", [Expired Enrollments],
            "Completed", [Complete Enrollments],
            "Abandoned", [Abandoned Enrollments],
            DISTINCTCOUNT(ProgramEnrollments[Id])
        )

     

     

    It should be that simple...