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
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
Employee
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
Employee
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
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.