convert sql to dax measure

  • convert sql to dax measure

    Posted by DSC Communities on October 18, 2022 at 1:47 am
    • Ronie Soriano

      Member

      October 18, 2022 at 1:47 AM

      how to convert to dax measure below sql query..thank you

      select count(Encounter_No) as CASH_IPD
      from
      (
      select distinct
      Encounter_No,
      –Registration_No,
      –Company_Code,
      –Doctor_Code,
      Payment_TypeName,
      InvoiceNo
      from BI_OSR_Revenues
      where Tran_Month = 3 and Tran_Year = 2022
      and Payment_TypeName = ‘CASH (IPD)’
      and isnull(admission_Date,”) <> ”
      ) as t1

      ——————————
      Ronie Soriano
      ——————————

    • Tomas Torp

      Member

      October 18, 2022 at 6:42 AM

      I think this measure should give you the same result. You might want to remove KEEPFILTERS if you want the filter arguments in the CALCULATE-function to override external filters instead of adding to them, and you might want to remove some of the filter arguments completely from the measure and control those filters with a slicer instead:

      CASH_IPD =
      CALCULATE (
          COUNTROWS (
              SUMMARIZE (
                  BI_OSR_Revenues,
                  BI_OSR_Revenues[Encounter_No],
                  -- BI_OSR_Revenues[Registration_No],
                  -- BI_OSR_Revenues[Company_Code],
                  -- BI_OSR_Revenues[Doctor_Code],
                  BI_OSR_Revenues[Payment_TypeName],
                  BI_OSR_Revenues[InvoiceNo]
              )
          ),
          KEEPFILTERS ( BI_OSR_Revenues[Tran_Month] = 3 ),
          KEEPFILTERS ( BI_OSR_Revenues[Tran_Year] = 2022 ),
          KEEPFILTERS ( BI_OSR_Revenues[Payment_TypeName] = "CASH (IPD)" ),
          KEEPFILTERS ( NOT ( ISBLANK ( BI_OSR_Revenues[admission_Date] ) ) )
      )?

      ——————————
      Tomas
      ——————————
      ——————————————-

    • Ronie Soriano

      Member

      October 18, 2022 at 7:44 AM

      Thank you sir and is working perfectly

      ——————————
      Ronie Soriano
      ——————————
      ——————————————-

    DSC Communities replied 3 years ago 1 Member · 0 Replies
  • 0 Replies

Sorry, there were no replies found.

The discussion ‘convert sql to dax measure’ is closed to new replies.

Start of Discussion
0 of 0 replies June 2018
Now

Welcome to our new site!

Here you will find a wealth of information created for peopleĀ  that are on a mission to redefine business models with cloud techinologies, AI, automation, low code / no code applications, data, security & more to compete in the Acceleration Economy!