0

I need to compare months in power bi. "How many incidents happened in may versus june". I know how to group up incidents to places but i dont know how to split incidents into months.

Sourcedata: two tables, Place and Incidents

enter image description here

Idea is to query this result directly from database using postreSQL. Then i can pick the months which i want to compare in power bi. But i do not know how to split months into columns. Each month creates a new column. Any suggestions?

Data contains over 100 places, over 10 000 incidents and over 20 months.

RADO
  • 7,733
  • 3
  • 19
  • 33
  • 1
    not sure I understand... you want to create the "result" in a database and then import it to Power BI? – RADO May 21 '19 at 22:10
  • my power bi is connected to database which contains those two tables. So i want to do a query in power bi query editor which gives me the "result" result. – problematic111 May 22 '19 at 10:01

1 Answers1

0

You can do that with the crosstab function from the tablefunc extension, check e.g. this answer: https://stackoverflow.com/a/11751905/571215

Full documentation here: https://www.postgresql.org/docs/current/tablefunc.html

C. Ramseyer
  • 2,322
  • 2
  • 18
  • 22