4 Replies Latest reply on Sep 5, 2018 6:33 PM by Okechukwu Ossai

# DAX Formula to Tableau

Hi all, I'm wondering if is possible to pass this formula:

Fired =

VAR currDate =     MAX ('Table1'[Date])

VAR currList =     CALCULATETABLE (         VALUES ( 'Table1'[EmployeeID] ),         FILTER (             ALLSELECTED ( 'Table1' ),             [Date] >= DATE ( YEAR ( currDate ), MONTH ( currDate ), 1 )                 && [Date]                     <= DATE ( YEAR ( currDate ), MONTH ( currDate ) + 1, 1 )                         - 1         )     )

VAR prevList =     CALCULATETABLE (         VALUES ( 'Table1'[EmployeeID] ),         FILTER (             ALLSELECTED ( 'Table1' ),             [Date]                 >= DATE ( YEAR ( currDate ), MONTH ( currDate ) - 1, 1 )                 && [FechaPago]                     <= DATE ( YEAR ( currDate ), MONTH ( currDate ), 1 ) - 1         )     )

RETURN     COUNTROWS ( EXCEPT ( prevList, currList ) )         + IF ( DISTINCTCOUNT ( 'Table1'[EmployeeID] ) <> 0, 0, BLANK () )

I've been trying to do this in Tableau but it appears that is not possible or I don't know how to.

Any help is appreciated.

Regards,

Julián.

• ###### 1. Re: DAX Formula to Tableau

Hola Julian,

Have you copy pasted this formula from SQL or another platform?

It looks like the syntax is somewhat different to Tableau. Could you explain what the formula is supposed to do and attach a sample data set?

Cheers,

Sasha

• ###### 2. Re: DAX Formula to Tableau

HI Julian,

Please attach the workbook/ data with expected output.

As the formula doesn't look familiar from Tableau.

• ###### 3. Re: DAX Formula to Tableau

The copied code is from Power BI, specifically from DAX which is used to do advanced calculations there. What I want to do is something like this:

It caculates the Hired/Fired employees against previous month. Everything that i'm expecting is in the link provided.

Regards,

Julián

• ###### 4. Re: DAX Formula to Tableau

Hi Julian,

You can use LOD expressions to recreate Power BI's CALCULATE function which returns a scalar.

CALCULATETABLE, on the other hand returns a virtual table which can be filtered, so there is no like-for-like equivalent in Tableau. However, Tableau is versatile and you can rewrite that formula in several ways. I have provided a solution in the original thread. Your data needs some restructuring and possibly data aggregation to reduce extract size.

Ossai