cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

Create a Measure based on logic of SQL Query

Hi,

I have a SQL Query as below :

select s.TERM_START_DATE
, s.TERM_END_DATE
, S.MONTH_END_DATE
, S.COLLEGE_CODE
, s.LEVEL_CODE
, Round (SUM(S.TERM_OTP)/COUNT(S.TERM_OTP),4) *100 OTP_PCT
from wgubi.vw_rst_student s
where s.month_begin_Date >= '01-dec-2018'
and s.term_start_date >= '01-dec-2018'
AND S.TERM_END_DATE < SYSDATE
AND S.TERM_OTP IS NOT NULL
AND S.STUDENT_PIDM NOT IN (select student_pidm from WGUBI.INF_STUDENT_GRADS where DEGREE_status_CODE = 'AW')
AND TRUNC(S.TERM_END_DATE) = S.MONTH_END_dATE
GROUP BY s.TERM_START_DATE
, s.TERM_END_DATE
, S.MONTH_END_DATE
, S.COLLEGE_CODE
,s.LEVEL_CODE
ORDER by 1;
 
Using "Import Mode", I connected all the requried tables to PowerBI and joined them.
Now, Using DAX, I created a Measure for "OTP_PCT" as :
OTP_PCT  = CALCULATE(
Round(SUM(VW_RST_STUDENT[TERM_OTP])/count(VW_RST_STUDENT[TERM_OTP]),4),
filter (INF_STUDENT_GRADS,INF_STUDENT_GRADS[DEGREE_STATUS_CODE]<> "AW"),
filter(VW_RST_STUDENT, VW_RST_STUDENT[TERM_OTP] in {0,1}))
 
 
It's giving wrong results.
Kindly help me.
 
Also please suggest how to use Blank Query for the same.
2 REPLIES 2
Community Support Team
Community Support Team

Re: Create a Measure based on logic of SQL Query

Hi @vijayaedupu92 ,

 

Could you please share your sample data and excepted result to me if you don't have any Confidential Information. Please upload your files to One Drive and share the link here.

 

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

Re: Create a Measure based on logic of SQL Query

What exactly are you trying to calculate? An average?

And why do you say the results are wrong?

Helpful resources

Announcements
Can You Solve These Challenge

Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

Community News & Announcements

Community News & Announcements

Get your latest community news and announcements.

Virtual Launch Event

Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

Community Kudopalooza

Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Users Online
Currently online: 47 members 819 guests
Please welcome our newest community members: