KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Combine 2 datasources in a query in a Dashboard widget #3130

Open John opened this topic on on Aug 29, 2023 - 2 comments

John commented on Aug 29, 2023

Hello, I use Dashboard and i need more than one Datasource in a Widget. I read articles like this or this one. Unfortunatelly they are not enough for me as I need to combine 2 different datasources in a query (in Dashboard). For example, in a case i have an excel datasource and a mySQL datasource. Excel file has data from 2015 to 2021 and mySQL database from 2022 and furthermore and i need to show all in a table or chart. In other case i have different mySQL databases and i want to combine tables among them in a query. Do you have any suggestion?

KoolReport commented on Aug 30, 2023

That's nice questions, you can do as following:

protected function dataSource()
{
    $previousData = Excel::file("myExcelFile2025to2021.xls")->run();
    $recentData = MySQLSource::table("myTable")->run();
    return array_merge($previousData->toArray(),$recentData->toArray());
}

Let us know if you need further assistance.

John commented on Aug 30, 2023

Thank you very much! I'll work on this.

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed

Dashboard