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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
basim
Frequent Visitor

how to implement below query in power bi

how to implement this query in power bi

 


select epu.[Project Status] INTO #temp from pjrep.MSP_EpmProject_UserView epu (nolock) where
([Project Departments] = @ProjectDepartmentName or @ProjectDepartmentName = '-1') and
([Concept Type] = @ConceptType or @ConceptType = '-1') and
([Primary Technology Department] = @PrimaryTechnologyDepartment or @PrimaryTechnologyDepartment = '-1') and
([Business Sponsor] like '%' + @CommercialProductOwner + '%' or @CommercialProductOwner = '-1')

select
(select count(*) from #temp where [Project Status] = 'On Schedule' ) as Green,
(select count(*) from #temp where [Project Status] = 'Not Started' or [Project Status] = 'Possible Delayed' ) as Yellow,
(select count(*) from #temp where [Project Status] = 'Delayed' or [Project Status] = 'Suspended' ) as Red

1 ACCEPTED SOLUTION

The proper answer is below :

 

 Use CALCULATE function and get (Project Status) data in PIE chart.

 

Get all parameters into three drop downlists.

 

then drag and drop Project Status on PIE Chart. 

View solution in original post

5 REPLIES 5
v-jiascu-msft
Microsoft Employee
Microsoft Employee

Hi @basim,

 

Could you please mark the proper answers as solutions?

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

The proper answer is below :

 

 Use CALCULATE function and get (Project Status) data in PIE chart.

 

Get all parameters into three drop downlists.

 

then drag and drop Project Status on PIE Chart. 

Thank you so much for sharing with us. @basim,

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-jiascu-msft
Microsoft Employee
Microsoft Employee

Hi @basim,

 

Seems you want a DAX formula. It could be like below. But the details are based on your data. If you need it, please provide a sample data.

#temp = filter(
selectcolumns(msp_epmproject_userview, 
"Project Status", [project status]), 
([project departments] = @ProjectDepartmentName 
          OR @ProjectDepartmentName = '-1' ) 
&& ( [concept type] = @ConceptType OR @ConceptType = '-1' ) 
&& ( [primary technology department] = @PrimaryTechnologyDepartment OR @PrimaryTechnologyDepartment = '-1' ) 
&& ( [business sponsor] LIKE '%' + @CommercialProductOwner + '%' OR @CommercialProductOwner = '-1' ) 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi @basim,

 

You can use this SQL query directly in Power BI.

 

Go To > 

Get Data > Sql Server > Advance options > Put your Sql Query.Untitled picture.png

Make sure you have last statement as select * from #temp , so that you query should return something.

 

Thanks,

Jayant

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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