Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago

Help with migrating a calculation from Tableau to PowerBI

Tableau Calc: 

{FIXED[Prod_ Order No_],[Prod_ Order Line No_]: MIN(IIF([No_]="FINPRINT",[Posting Date],

({FIXED[Prod_ Order No_],[Prod_ Order Line No_]: MIN(IIF(([No_]="SMARTCARD VAULT" OR [No_]="FINCARD VAULT"),[Posting Date],NULL) )})

))}

 

Tried to replicate it in PowerBI but dont know how to get around the IIF function:

Date Finished = IF('Wastage Data'[No_] = "FINPRINT",
CALCULATE(
LASTDATE('Wastage Data'[Posting Date]),
ALLEXCEPT('Wastage Data','Wastage Data'[Prod_ Order No_],'Wastage Data'[Prod_ Order Line No_])),
IF(('Wastage Data'[No_] = "SMARTCARD VAULT" || 'Wastage Data'[No_] = "FINCARD VAULT"),
CALCULATE(
LASTDATE('Wastage Data'[Posting Date]),
ALLEXCEPT('Wastage Data','Wastage Data'[Prod_ Order No_],'Wastage Data'[Prod_ Order Line No_])),
0))
 
Any help is appreciated

4 Replies

  • Many of us here are not fluent in Tableau. Can you explain what the calculation is intended to do and share some sample input and desired output as an example to test against?

  • Hello there! Its kinda hard to understand the use of this measure but you can check if this does what you want:

     

     

    Date Finished =
    VAR _lastdate =
        CALCULATE (
            LASTDATE ( 'Wastage Data'[Posting Date] ),
            ALLEXCEPT (
                'Wastage Data',
                'Wastage Data'[Prod_ Order No_],
                'Wastage Data'[Prod_ Order Line No_]
            )
        )
    RETURN
        IF (
            SELECTEDVALUE ( 'Wastage Data'[No_] ) in { "FINPRINT", "SMARTCARD VAULT", "FINCARD VAULT"},
            _lastdate,
            0
    )

     

     

    Hope this answer solves your problem!
    If you need any additional help please @ me in your reply.
    If my reply provided you with a solution, please consider marking it as a solution ✔️ or giving it a kudoe 👍
    Thanks!

    You can also check out my LinkedIn!

    Best regards,
    Gonçalo Geraldes

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank You all for your attempts. I just made the calculation more complicated then I had to. 

       

      The answer is below for anyone who runs into a similar problem:

       

       

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi Anonymous,

        Perhaps you can try using the following measure formula if helps:

        Measure =
        CALCULATE (
            MAX ( 'Wastage Data'[Posting Date] ),
            FILTER (
                ALLSELECTED ( 'Wastage Data' ),
                'Wastage Data'[No_] IN { "FINPRINT", "SMARTCARD VAULT", "FINCARD VAULT" }
            ),
            VALUES ( 'Wastage Data'[Prod_ Order No_] ),
            VALUES ( 'Wastage Data'[Prod_ Order Line No_] )
        )

        If these also don't help, please share more detailed information to help us clarify your scenario to test.

        How to Get Your Question Answered Quickly 

        Regards,

        Xiaoxin Sheng