Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
luisfgfurtado
Regular Visitor

SQL dynamic filter (relation by sql query)

I'm trying to use Power BI to make some reports for our Redmine. The Redmine uses MySQL database.
I already connected PowerBi direct to MySQL database and imported all tables that I need.
The problem is the way of Redmine relates projects and sub projects. All the projects are in the same table and two fields "lft" and "rgt" are used to determine the position of projects in a very large tree.
When I need to filter all children projects of a parent project, I use:

 

SELECT
*
FROM
(
SELECT * FROM `projects`
WHERE `identifier` like 'aprimora-ef'
) as mp
INNER JOIN `projects` p on p.`lft` BETWEEN mp.`lft` AND mp.`rgt`

Have some way to include this kind of filter in PowerBI?
I would like to display a list of some projecs and a table filtered by selected project including a total of issues of the selected

project and their subprojects.

 

 

thanks

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

Not sure I fully understand your issue but will take a whack at it. You can relate tables to one another, so if you have a project table, you could import it twice (the second would be for relating to sub-projects), you could then have a slicer for project identifiers and it would slice a table that would display your sub-projects and issues.

 

Some example data and desired output might help clarify things.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Greg_Deckler
Super User
Super User

Not sure I fully understand your issue but will take a whack at it. You can relate tables to one another, so if you have a project table, you could import it twice (the second would be for relating to sub-projects), you could then have a slicer for project identifiers and it would slice a table that would display your sub-projects and issues.

 

Some example data and desired output might help clarify things.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

How did you make the connection? Can you send an example please? Thanks.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors
Top Kudoed Authors