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
jvdl
Frequent Visitor

Two questions on embedded dataselected events

Q1: On a report, the data selected event is fired for some type of visuals but not on others.

Visuals fired: pies, (stacked) column charts.

Not fired: maps, doughnuts, bar charts.

 

Any ideas what may cause that? I am using the latest powerbi.js from github.

 

Q2: The "filter" part of the fired event details is not helpful.

See "filters" at the end of the JSON below. Itdoes not give clues to which columns/tables are filtered on.

I happen to know that the filter is "WHERE Year = IN (2016, 2017) and [sales].revenue > $10".

 

But how can the code figure that out?

 

{
 "report": {
  "id": "****-****-****-****-****",
  "displayName": "test report"
 },
 "page": {
  "name": "ReportSection",
  "displayName": "Sales 12 months rolling"
 },
 "visual": {
  "name": null,
  "title": "revenue by Month and Year",
  "type": "clusteredColumnChart"
 },
 "dataPoints": [
  {
   "identity": [
    {
     "target": {
      "table": "LocalDateTable_****-****-****-****-****",
      "column": "Month"
     },
     "equals": "March"
    },
    {
     "target": {
      "table": "LocalDateTable_****-****-****-****-****",
      "column": "Year"
     },
     "equals": 2017
    }
   ],
   "values": [
    {
     "target": {
      "table": "vw_kpi_all_sales",
      "column": "revenue",
      "aggregationFunction": "Sum"
     },
     "value": *****,
     "formattedValue": "*****"
    }
   ]
  }
 ],
 "regions": null,
 "filters": [
  {
   "$schema": "http://powerbi.com/product/schema#basic",
   "target": null,
   "operator": "In",
   "values": [
    2017,
    2016
   ]
  },
  {
   "$schema": "http://powerbi.com/product/schema#advanced",
   "logicalOperator": "And",
   "conditions": [
    {
     "operator": "GreaterThan",
     "value": 10
    }
   ]
  }
 ]
}
3 REPLIES 3
Eric_Zhang
Employee
Employee


@jvdl wrote:

Q1: On a report, the data selected event is fired for some type of visuals but not on others.

Visuals fired: pies, (stacked) column charts.

Not fired: maps, doughnuts, bar charts.

 

Any ideas what may cause that? I am using the latest powerbi.js from github.

 

Q2: The "filter" part of the fired event details is not helpful.

See "filters" at the end of the JSON below. Itdoes not give clues to which columns/tables are filtered on.

I happen to know that the filter is "WHERE Year = IN (2016, 2017) and [sales].revenue > $10".

 


@jvdl

Q1: On a report, the data selected event is fired for some type of visuals but not on others.

Based on my test, the dataselected event doesn't fire for the map, but for bar, doughnuts visuals. This event will be triggered by selections on the visuals those you can "select", I mean "select" reflection as below snapshot.

Capture.PNG

 

Q2: The "filter" part of the fired event details is not helpful.

In my test, I observed that the visual level filter is contained in the dataselected event JSON, while page/report level filters are not. If your issue refer  to report level filter, you could try console.log(report.getFilters());

Capture.PNG

@Eric_ZhangMade another report that is similar, except that it is "Direct Query" on an Azure database, while the other one was "Imported" from an on-premises database (the Azure is actually a copy of the on premises one).

 

On this new report, the dataselected event is fired on every type of visual.

And also the "filters" part gives (almost) what I'm looking for, which is, since you ask, the visual level filters that the user has selected from the filters sidebar.

 

In JSON sample below, that is the filter WHERE customer_desc IN (..., ....) AND revenue > 10

 

The revenue column is not mentioned in the JSON but I assume that is because is implicit because it the metric of that visual (which is provided else where in the visua

 

 "filters": [
  {
   "$schema": "http://powerbi.com/product/schema#basic",
   "target": {
    "table": "vw_kpi_all_sales",
    "column": "customer_desc"
   },
   "operator": "In",
   "values": [
    "Wa****rt",
    "De****ze"
   ]
  },
  {
   "$schema": "http://powerbi.com/product/schema#advanced",
   "logicalOperator": "And",
   "conditions": [
    {
     "operator": "GreaterThan",
     "value": 10
    }
   ]
  }
 ]

 

jvdl
Frequent Visitor

Explanation of the business problem I'm trying to solve

  • The PBI reports shows KPI of data warehouse about plans and predicted future events.
  • That data warehouse cube is produced by an application from raw SQL DB numbers, which are produced by the application and its users.
  • The PBI report is embedded in that application
  • The user looks at the report and sees for example a slice of pie that doesn't look right.
  • The user clicks on that slice
  • The application captures that event and then tries to figure out from the combined report, page and visual filters; as well as the selted "identities" of that slice and deduct which "slice & dice" that represents in the data warehouse cube; and which tables & joins that corresponds to in SQL, which WHERE clause applies.
  • Then it brings up UI from application where user can see and edit the raw data that make up the "slice of the pie" so the user can set the wrongs right.
  • The ability to edit is the crux of the biscuit here: drilling down to only see the details could be done in PBI itself - no need for embedding.

 

Problems encountered

  • Solved: The selection events & visual filters didn't come out well, this has been solved by re-creating the report.
  • Unsolved: The page & report filters don't come out (see screenshot below). There is a page filter active (date in the last year) but I'm not capable to extract it in code. The getFilters() methods don't tell about it.

 

PBI Filters.PNG

 

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.