Forum Discussion
Multiple dataViewMappings
- 1 year ago
This work around worked for me. This approach makes the aggregatedTotals measure repeat the same total for each date row — so you can show both the sparkline and the overall KPI side-by-side.
1. Create a DAX measure for the aggregate over a fixed date range (I used variables instead of hardcoded dates):
TotalBetweenDates =
CALCULATE(
[Total],
FILTER(
ALL('Date'),
'Date'[Date] >= DATE(2025,1,1) && 'Date'[Date] <= DATE(2025,3,31)
)
)2. Add the new data role in capabilities.json:
{
"displayName": "Aggregated Totals",
"name": "aggregatedTotals",
"kind": "Measure"
}3. Include the aggregate measure in your dataViewMappings:
"dataViewMappings": [
{
"categorical": {
"categories": { "for": { "in": "metric" } },
"values": {
"group": {
"by": "date",
"select": [
{ "for": { "in": "total" } },
{ "for": { "in": "target" } },
{ "for": { "in": "kpi" } },
{ "for": { "in": "aggregatedTotals" } }
]
}
}
}
}
]
This work around worked for me. This approach makes the aggregatedTotals measure repeat the same total for each date row — so you can show both the sparkline and the overall KPI side-by-side.
1. Create a DAX measure for the aggregate over a fixed date range (I used variables instead of hardcoded dates):
TotalBetweenDates =
CALCULATE(
[Total],
FILTER(
ALL('Date'),
'Date'[Date] >= DATE(2025,1,1) && 'Date'[Date] <= DATE(2025,3,31)
)
)
2. Add the new data role in capabilities.json:
{
"displayName": "Aggregated Totals",
"name": "aggregatedTotals",
"kind": "Measure"
}
3. Include the aggregate measure in your dataViewMappings:
"dataViewMappings": [
{
"categorical": {
"categories": { "for": { "in": "metric" } },
"values": {
"group": {
"by": "date",
"select": [
{ "for": { "in": "total" } },
{ "for": { "in": "target" } },
{ "for": { "in": "kpi" } },
{ "for": { "in": "aggregatedTotals" } }
]
}
}
}
}
]