Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

SQL to DAX Conversion

Hi everyone,

 

I have a working SQL query that I would like to put into PowerBI.  I'm not sure exaclty how to convert SQL to DAX so any help would greatly be appreciated thanks!

 

SELECT Left(AcademicSemester,3),
AcademicWeek, SUM(Swipe)/COUNT(Distinct AcademicSemester)
as AverageSwipe
FROM
Table
Where AcademicWeek is not NULL
Group BY AcademicWeek, Left(AcademicSemester,3)

  • Anonymous ,

     

    You need have a new colum
    AcademicSemester new= Left(Table[AcademicSemester],3)

    Then put these two on visual AcademicSemester new , Table[AcademicWeek ] as unsummarize
    and use this mesure
    measure = divide(SUM(Table[Swipe]),Distinctcount(Table[AcademicSemester]))

4 Replies

  • Anonymous ,

     

    You need have a new colum
    AcademicSemester new= Left(Table[AcademicSemester],3)

    Then put these two on visual AcademicSemester new , Table[AcademicWeek ] as unsummarize
    and use this mesure
    measure = divide(SUM(Table[Swipe]),Distinctcount(Table[AcademicSemester]))

  • Hi Anonymous ,

     

    Please provide some sample data that you are uisng.

     

    Thanks,

    Pragati

    • Anonymous's avatar
      Anonymous
      Not applicable

      Pragati11 

      Here is sample data

      AcademicSemesterAcademicWeekAverageSwipe
      Spr310,250.5
      Fal1025,508.6
      Sum48,765.8