Forum Discussion

phuongui's avatar
phuongui
Frequent Visitor
9 years ago
Solved

Can not New Table or use DAX function in DirectQuery mode

Dear all,

 

I have a problem when use DirectQuery mode to get SQL Server Database. I turned on "Allow unrestricted measures in DirectQuery mode" but it can use another features such as, New Table or DAX function.

 

How can I fix this problem?

Thanks,

Phuong

  • Hi phuongui,

    Creating a new table is not allowed in Direct Query even if you Allow Restricted stuff.

    I faced the same problem at my end but since i had to create a small table of 7 rows and 2 columns, i did the following:

    1. In Query Editor Section, right click on your any of the existing table and click on duplicate.
    2. Rename it, Now in PowerQuery section, remove the steps, if any, after Source.
    3. Edit source and wriite a custom SQL query to create your own table.

    Note: By creating table i mean, use SELECT and UNION ALL to create your table.
    Eg:

    SELECT 1 AS [StudentID]
    ,'Ryan' AS [StudentName]
    
    UNION ALL
    
    SELECT 2 AS [StudentID]
    ,'David' AS [StudentName]

    This approach can be useful if you have to create small table and when you can't afford to switch from DirectQuery mode to other.

    Thanks !!

  • Hi phuongui,

    As far as i know, FORMAT is not allowed while creating a 'Column' in DAX. It can be used while creating a 'Measure'
    Nevertheless, if you just want to take month from Date colulm, use below DAX, it will work for sure:

    MonthColumn = MONTH([Date])

    Thanks !!

14 Replies

  • prateekraina's avatar
    prateekraina
    Memorable Member

    Hi phuongui,

    Creating a new table is not allowed in Direct Query even if you Allow Restricted stuff.

    I faced the same problem at my end but since i had to create a small table of 7 rows and 2 columns, i did the following:

    1. In Query Editor Section, right click on your any of the existing table and click on duplicate.
    2. Rename it, Now in PowerQuery section, remove the steps, if any, after Source.
    3. Edit source and wriite a custom SQL query to create your own table.

    Note: By creating table i mean, use SELECT and UNION ALL to create your table.
    Eg:

    SELECT 1 AS [StudentID]
    ,'Ryan' AS [StudentName]
    
    UNION ALL
    
    SELECT 2 AS [StudentID]
    ,'David' AS [StudentName]

    This approach can be useful if you have to create small table and when you can't afford to switch from DirectQuery mode to other.

    Thanks !!

    • phuongui's avatar
      phuongui
      Frequent Visitor

      But why I can not type DAX function in DirectQuery mode? I choose New Colume, just get month from date column with FORMAT keyword, it doesn't work. Maybe create new table is not necessary, even when DAX function is unavailable too... :(

      • prateekraina's avatar
        prateekraina
        Memorable Member

        Hi phuongui,

        As far as i know, FORMAT is not allowed while creating a 'Column' in DAX. It can be used while creating a 'Measure'
        Nevertheless, if you just want to take month from Date colulm, use below DAX, it will work for sure:

        MonthColumn = MONTH([Date])

        Thanks !!

  • vanessafvg's avatar
    vanessafvg
    Community Champion

    as far as i know this is not a bug but the nature of using direct query, if you want to create tables etc you need to use imported mode.

    • phuongui's avatar
      phuongui
      Frequent Visitor

      Yes, in Imported mode everything is ok. But when I use DirectQuery mode and Allow unrestricted measures but it's not work...

      • vanessafvg's avatar
        vanessafvg
        Community Champion

        correct, i think direct query mode expect you to have done most of the modelling in your source - so you will either need to push back the requirement to your source or swap to imported mode.