Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Calculated column taking forever

Hi, i have a copied formula that has been working for all the other Power Bi desktop reports so far. But for a new client that has over 1.2 million rows which i think is the problem here, the followi...
  • goncalogeraldes's avatar
    4 years ago

    Hello there Anonymous ! My tip would be to never use calculated columns, specially in Fact tables! You can do the same query in the Query Editor instead of DAX.

     

    Another option is to store the results in a measure, or variable within a measure, and lighten the storage that PBI needs.

     

    In terms of code, you can lighten it with variables like so:

     

     

    Distinct Years of Giving =
    VAR _count =
        CALCULATE (
            DISTINCTCOUNT ( GIFT_TABLE[Gift Date].[Year] ),
            FILTER ( GIFT_TABLE, GIFT_TABLE[donor_id] = DONOR_TABLE[donor_id] )
        )
    RETURN
        IF ( _count > 0, _count, 0 )

     

     

    Again, I reinforce that you should do this as a measure and not a calculated column. You can check further documentation on the use cases of both measures and calculated columns in the following link.

     

    Measure vs Calculated Column: The Mysterious Question? Not! - RADACAD

     

    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