Forum Discussion

Jaxidian's avatar
Jaxidian
Frequent Visitor
9 years ago
Solved

Need a leading zero on a Month with DirectQuery

So I have a table that looks like this: ID int [Value] decimal(29,9) DateForSearching datetime YearNumber int MonthNumber int DayNumber int HourNumber int   I want to do a bunch of visua...
  • v-huizhn-msft's avatar
    v-huizhn-msft
    9 years ago

    Hi Jaxidian,

    First, you should click File -> Options and then Settings -> Options -> DirectQuery, then selecting the option "Allow unrestricted measures in DirectQuery mode" shown in following screenshot. When that option is selected, you can create calculated column and measures.



    As I tested, If function can be used in DirectQuery Model. I reproduce your scenario(connect to SQL Server database) and get the expected result. Create a column using th following formula, please see the result in screenshot below.

    Year-month = IF('HumanResources vEmployeeDepartment'[Month]<=10,CONCATENATE('HumanResources vEmployeeDepartment'[Year],CONCATENATE("-0",'HumanResources vEmployeeDepartment'[Month])),CONCATENATE('HumanResources vEmployeeDepartment'[Year],CONCATENATE("-",'HumanResources vEmployeeDepartment'[Month])))






    Please ckeck if you invoke creating calculated columns and measures as the solution above. If you have any question, please let me know.

    Best Regards,
    Angelia