Forum Discussion

oluong's avatar
oluong
Icon for Helper I rankHelper I
4 years ago
Solved

Comparison of data using multiple slicer

I've poured through so many forums and youtube videos on comparison using one or more slicer, none of them seem to work for me.  I try those same example into my data and could not achieve what I want.  Perhaps the great minds of the community can assist me.  The objective:

 

I have a data table name workforce with columns company/agencies, race, year, value

 

Company_or_agencyRaceYearValue
ATotal Males202012
ATotal Males %202010
ATotal Females20202
ATotal Females %202080.33
AHispanic or Latino Male20201
AHispanic or Latino Male %20208.33
AHispanic or Latino Female20200
AHispanic or Latino Female %20200
AWhite Male20209
AWhite Male %202075
AWhite Female20201
AWhite Female %20208.33
ABlack or African American Male20200
ABlack or African American Male %20200
ABlack or African American Female20201
ABlack or African American Female %20208.33
AAsian Male20200
AAsian Male %20200
AAsian Female20200
AAsian Female %20200
ATotal Males201912
ATotal Males %201980
ATotal Females20193
ATotal Females %201920
AHispanic or Latino Male20191
AHispanic or Latino Male %20196.67
AHispanic or Latino Female20191
AHispanic or Latino Female %20196.67
AWhite Male201911
AWhite Male %201973.33
AWhite Female20190
AWhite Female %20190
ABlack or African American Male20190
ABlack or African American Male %20190
ABlack or African American Female20192
ABlack or African American Female %201913.33
AAsian Male20190
AAsian Male %20190
AAsian Female20190
AAsian Female %20190

 

Then I created one table DimCompanyAgency that list all possible companies with a relationship to workforce.company_or_agency.

Then I created another create DimCompanyComparator with same data as DimCompanyAgency with an inactive relationship

 

Here is the interface management want.  I even try to convince them to consolidate the drop down to one, but they want 3.  First drop down is primary company, second drop is for comparing against company 2, and third drop down against company 3.  

 

So What I want to do is have those 3 slicer filter the workforce table to only have records that pertain to the 3 slicers and straight display of the data using table.

 

 

Is it possible to program the 3 seperate slicer to make the workforce table contain only rows that have companies from slicer 1,2,3? or may be i'm approaching the idea the wrong way!!!

 

Thank you community if you can help me solve this problem.

 

  • Hi oluong ,

     

    How about something like this?

    Measure = 
    VAR SelectedCompany2_ =
        SELECTEDVALUE ( DimCompanyAgency[Company_or_agency] )
    VAR SelectedCompany3_ =
        SELECTEDVALUE ( DimCompanyComparator[Company_or_agency] )
    VAR MainComapny_ =
        SUM ( workforce[Value] )
    VAR Company2_ =
        CALCULATE (
            SUM ( workforce[Value] ),
            workforce[Company_or_agency] = SelectedCompany2_
        )
    VAR Company3_ =
        CALCULATE (
            SUM ( workforce[Value] ),
            workforce[Company_or_agency] = SelectedCompany3_
        )
    RETURN
        SWITCH (
            SELECTEDVALUE ( Company[Company] ),
            "Main Company", MainComapny_,
            "Company 2", Company2_,
            "Company 3", Company3_
        )
    

     

    For more details, check the attachment.

     

     

     

    Best Regards,

    Icey

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

1 Reply

  • Icey's avatar
    Icey
    Icon for Community Support rankCommunity Support

    Hi oluong ,

     

    How about something like this?

    Measure = 
    VAR SelectedCompany2_ =
        SELECTEDVALUE ( DimCompanyAgency[Company_or_agency] )
    VAR SelectedCompany3_ =
        SELECTEDVALUE ( DimCompanyComparator[Company_or_agency] )
    VAR MainComapny_ =
        SUM ( workforce[Value] )
    VAR Company2_ =
        CALCULATE (
            SUM ( workforce[Value] ),
            workforce[Company_or_agency] = SelectedCompany2_
        )
    VAR Company3_ =
        CALCULATE (
            SUM ( workforce[Value] ),
            workforce[Company_or_agency] = SelectedCompany3_
        )
    RETURN
        SWITCH (
            SELECTEDVALUE ( Company[Company] ),
            "Main Company", MainComapny_,
            "Company 2", Company2_,
            "Company 3", Company3_
        )
    

     

    For more details, check the attachment.

     

     

     

    Best Regards,

    Icey

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.