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
Anonymous
Not applicable

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
ananeto
New Member

What exactly are you trying to calculate? An average?

And why do you say the results are wrong?

v-frfei-msft
Community Support
Community Support

Hi @Anonymous ,

 

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 others find it more quickly.

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.

Top Solution Authors