Forum Discussion
Need a leading zero on a Month with DirectQuery
- 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
You should able to do it by using if condition
Year-Month = 'Calendar'[Year] & "-" & if('Calendar'[Month Number] < 10, "0", BLANK()) & 'Calendar'[Month Number] - Jaxidian9 years agoFrequent VisitorIt tells me I cannot use an IF in a DirectQuery report.
- parry2k9 years agoSuper User
I just used the formula on direct query.
What is your data source for direct query? Are you using Live COnnection?
- Jaxidian9 years agoFrequent VisitorIt's direct-to-Azure SQL Database (no caching/syncing).
I thought "DirectQuery" was synonymous with a "live connection". If that's untrue then my terminology is mixed up.