Forum Discussion

diaAzul's avatar
diaAzul
Advocate IV
8 years ago
Solved

Custom Visual - Selecting, Filtering and Highlighting

I am developing a series of custom visual, one of which is a population pyramid. The code for the visual is on Github: https://github.com/DiaAzul/powerBI-visual-PopPyramid3/tree/Version-1.10.0   T...
  • diaAzul's avatar
    diaAzul
    8 years ago

    v-viig

     

    Partial solution to the selection problems (issues 1 and 2), but not the fact that other visuals are filtered not highlighted (3).

     

    The problem stems from the fact that when more than one category column is add to createSelectionIdBuilder() it causes the cross-filtering to error when more than one data point is selected.

     

    The fix is to only add one category column to the createSelectionIdBuilder - it doesn't matter which one, and the values in the column appear to be irrelevant. This is counter intuitive if comparing with an SQL select, or any other filtering function which would look to match against the values in the category columns. The resultant code (showing the removed line commented out) is as follows:

     

    const selectionId: ISelectionId = this.host.createSelectionIdBuilder()
        .withCategory(ageRange, i)
        // .withCategory(gender, i)
        .createSelectionId();

    It would be helpful if PowerBI provided a more useful error message, or error checking, to advise that more than one category is not permitted when cross filtering; or even, have a solution which doesn't throw an error when more than one category is selected.