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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
allaboutdata
Advocate II
Advocate II

DataViewMapping in capabilities, specifying 3 different categorical mappings

Hi All,

 

So i've setup my custom visual to have 3 dataviews in its capabilities. It seems though that its just duplicating the first categorical data view for the other 2. Anyone got any ideas?

 

In the visual playground where i control the data view mapping inputted the visual renders correctly. So i'm assuming it has to do with how the service is mapping the inputs to the mappings below.

 

dataViewMappings: [
            {
                categorical: {
                    categories: {
                        for: { in: 'A' },
                        dataReductionAlgorithm: { top: {} }
                    },
                    values: {
                        group: {
                            by: 'B',
                            select: [{ for: { in: 'Values' } }],
                            dataReductionAlgorithm: { top: {} }
                        }
                    },
                    rowCount: { preferred: { min: 2 }, supported: { min: 0 } }
                },
            },
            {
                categorical: {
                    categories: {
                        for: { in: 'ACategory' },
                        dataReductionAlgorithm: { top: {} }
                    },
                    values: {
                        group: {
                            by: 'A',
                            select: [{ for: { in: 'Values' } }],
                            dataReductionAlgorithm: { top: {} }
                        }
                    },
                    rowCount: { preferred: { min: 2 }, supported: { min: 0 } }
                },
            },
            {
                categorical: {
                    categories: {
                        for: { in: 'BCategory' },
                        dataReductionAlgorithm: { top: {} }
                    },
                    values: {
                        group: {
                            by: 'B',
                            select: [{ for: { in: 'Values' } }],
                            dataReductionAlgorithm: { top: {} }
                        }
                    },
                    rowCount: { preferred: { min: 2 }, supported: { min: 0 } }
                },
            }
        ]

 

 

5 REPLIES 5

dataViewMappings correspond to the dataRoles. What does your dataRoles section look like?

 

You can only map once, so having three is not correct. Something like this may get you closer. Note how the roles match the mappings. The best way to learn is to find a chart that behaves the way that you want and start from that example. If you log the dataview to the console, you can experiment and see how changes you make to capabilities affect the dataview.

 

dataRoles: [
    {
        name: "A",
        kind: VisualDataRoleKind.Grouping,
        displayName: "A"
    },
    {
        name: "B",
        kind: VisualDataRoleKind.Grouping,
        displayName: "B"
    },
    {
        name: "Values",
        kind: VisualDataRoleKind.Measure,
        displayName: "Values"
    }
],
dataViewMappings: [{
    categorical: {
        categories: {
            for: { in: "A" }
        },
        values: {
            group: {
                by: "B",
                    select: [{ bind: { to: 'Values' } }]
            }
        },
    }
}],

Hey Deldversveld,

 

Do you know for certain that you can only map once? Can you further iterate on that. Or are you saying that per data role you can only allocate to one datamapping?

 

If you take a look at the combo chart in the visualisation playground it has multiple dataviewmappings assosciated to it.

 

dataViewMappings: [
            {
                conditions: [
                    { 'Category': { max: 1 }, 'Series': { max: 0 } },
                    { 'Category': { max: 1 }, 'Series': { min: 1, max: 1 }, 'Y': { max: 1 } },
                ],
                categorical: {
                    categories: {
                        for: { in: 'Category' },
                        dataReductionAlgorithm: { top: {} }
                    },
                    values: {
                        group: {
                            by: 'Series',
                            select: [
                                { for: { in: 'Y' } }
                            ],
                            dataReductionAlgorithm: { top: {} }
                        }
                    },
                    rowCount: { preferred: { min: 2 }, supported: { min: 0 } }
                }
            }, {
                conditions: [
                    { 'Category': { max: 1 }, 'Series': { max: 0 }, 'Y2': { min: 1 } },
                    { 'Category': { max: 1 }, 'Series': { min: 1, max: 1 }, 'Y': { max: 1 }, 'Y2': { min: 1 } },
                ],
                categorical: {
                    categories: {
                        for: { in: 'Category' },
                        dataReductionAlgorithm: { top: {} }
                    },
                    values: {
                        select: [
                            { for: { in: 'Y2' } }
                        ],
                        dataReductionAlgorithm: { top: {} }
                    },
                    rowCount: { preferred: { min: 2 }, supported: { min: 0 } }
                },
            }
        ],

 

 

thoughts?

 

I was thinking a long your lines until i saw the combo chart. I have my base visualisation working with the single data view mapping.

 

This is really to activate category colouring but with two groupings and a single measure. As opposed to a combo chart which is one grouping i.e. axis and two measures.

You're right! I had not looked at the capabilities for combo chart. No suggestions on a solution, but I'll try to look into it later tonight.

yeah cool okay, keen to see if you can find the way to do it.

 

Knocking my head over it, you should be able to do it if the combo chart works that way.

Were you able to find a solution to this?  I am having the same struggle.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors