Donate

Function Format In DAX Not Allowed In DirectQuery Calculated Columns When Formatting Dates

Good evening fellow developers,

I have a scenario wherein I will set the default value of a slicer to the current month by default. A link in the forums presented the solution below.
Current Month = IF(MONTH('Transactions'[transdate])=Month(NOW()) && YEAR('Transactions'[transdate]) = YEAR(NOW()), "Current Month", Format('Transactions'[transdate], "YYYY mmmm"))
Since, I'm using DirectQuery connection, the Format() function isn't allowed in calculated columns. After doing some tweaking on my column, the fix that I've come up with was to extract the month and year individually and concatenate them and return that value to the Current Month column.
Current Month = IF(MONTH('Transactions'[transdate])=Month(NOW()) && YEAR('Transactions'[transdate]) = YEAR(NOW()), "Current Month", Year('Transactions'[transdate]) & "/" & Month('Transactions'[transdate]))

Cheers.. :)

Comments

Donate

Popular Posts From This Blog

WPF CRUD Application Using DataGrid, MVVM Pattern, Entity Framework, And C#.NET

How To Insert Or Add Emojis In Microsoft Teams Status Message

Pass GUID As Parameter To Action Using ASP.NET MVC ContribGrid