March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hi All!
I'm having some issues using the recommended `createDataViewWildcardSelector` when implementing conditional formatting for data with groupings.
Using the `CircleCard` demo visual (from `pbiviz new CircleCard`), if I add conditional formatting support for font size using:
fontSize = new formattingSettings.NumUpDown({
name: "fontSize",
displayName: "Text Size",
value: 12,
selector: dataViewWildcard.createDataViewWildcardSelector(dataViewWildcard.DataViewWildcardMatchingOption.InstancesAndTotals),
instanceKind: powerbi.VisualEnumerationInstanceKinds.ConstantOrRule
});
The resulting dataview (as expected) has `objects` bound to each category:
However, if I update the dataview mapping to additionally group values:
"dataViewMappings": [
{
"categorical": {
"categories": {
"for": {
"in": "category"
},
"dataReductionAlgorithm": {
"top": {}
}
},
"values": {
"group": {
"by": "grouping",
"select": [
{
"for": {
"in": "measure"
}
}
]
}
}
}
}
]
Then `objects` is no longer bound to the `categories` (or anywhere in the dataview, for that matter):
Is there an alternate method that should be used for grouping/series? I've been trying different ways of specifying the `selector` input, but have had no luck so far.
If it would be helpful, here's a repo with the (slightly) modified CircleCard example that reproduces the behaviour:
https://github.com/andrjohns/circleCard-demo
Thanks!
For any that come across this thread in the future, the solution that I found was to use a different kind of 'Wildcard' selector.
I found that the visuals API defined different types of data repetition selectors, specifically a role wildcard
So where the original implementation was:
fontSize = new formattingSettings.NumUpDown({
name: "fontSize",
displayName: "Text Size",
value: 12,
selector: dataViewWildcard.createDataViewWildcardSelector(dataViewWildcard.DataViewWildcardMatchingOption.InstancesAndTotals),
instanceKind: powerbi.VisualEnumerationInstanceKinds.ConstantOrRule
});
I followed the definition for creating the dataview wildcard selector and replaced the selector definition with:
fontSize = new formattingSettings.NumUpDown({
name: "fontSize",
displayName: "Text Size",
value: 12,
selector: { data: [{ roles: ["category"] }] },
instanceKind: powerbi.VisualEnumerationInstanceKinds.ConstantOrRule
});
With this change, the conditional formatting objects were then bound to 'categories' as before, even when a grouping series is used
Hi @andrjohns,
I've spent a little while looking at this. Your code looks good to me, and I think it's probably worth checking with MS to see if this is supported or a bug. This repo is a good way for them to quickly confirm if something is wrong, or if there is something else to do to make it work.
For groupings, I would expect the DataViewValueColumnGroup returned by categorical.values.grouped() to contain an objects property with the derived conditional formatting values. This does not happen.
To show my working, I have downloaded your repo and created a data set that looks like this:
So:
In my data view metadata, I get what I might expect: one entry for each field I added, then an additional four entries for the intersection of grouping x measure:
Expanding the last entry to confirm groupName of 2024 (last value of Calendar Year):
As I say, it's not a great example, but should hopefully demonstrate that things are happening as I expect so far.
When I try to add a measure to the conditional formatting field (we'll do an implicit measure of count of Calendar Year, because we have less entries in 2024 and can check the number is right), the array changes as follows:
Hopefully you will see that our array length is now 12 (up from 7). This is:
If we expand the final entry, we can see that it is indeed for groupName = 2024, and there is an additional property called relatedObjects (which I have also expended for youto show its structure):
You should be able to see that this has dataPoint.fontSize in its structure.
However, this is not part of the API, so we shouldn't rely on it. We can also see that there is no corresponding derived value in there anyway.
This is as much as I could find in the data view (I also downloaded the raw data view to check for occurrences of the fontSize object and it's definitely not there).
So, long story short, I'd contact MS at pbicvsupport@microsoft.com, to see if they can confirm what is gong wrong here, and if it isn't a bug, what the correct implementation should be for this use case. It would defininitely be useful to provide them with your repo and this thread for reference.
Good luck,
Daniel
Proud to be a Super User!
My course: Introduction to Developing Power BI Visuals
On how to ask a technical question, if you really want an answer (courtesy of SQLBI)
Hi Daniel,
Thanks for taking the time to dive in and investigate, it's much appreciated! Great to hear that it's not just me missing something obvious, I'll contact support and see what they say.
Thanks again!
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
4 | |
3 | |
1 | |
1 | |
1 |