Forum Discussion

ldwf's avatar
ldwf
Helper V
1 year ago
Solved

Add a calculated column to a dataflow

I have created several PBI dataflows with the intention of having them feed a PBI datamart.  I want to create some calculated fields in the flow using DAX, just like I do on PBI desktop.  However, I don't seem to see an option that would allow me to create calculated fields using DAX.  I do see the option to create a measure in the datamart, but I don't see anything about calculated fields.  How would I be able to build calculated fields using DAX?

  • Absolutely. Having these complex calculated columns in the first place is a design red flag. Don't forget -they eat up space AND compute when they are calculated.

6 Replies

  • There is no need for DAX.  use Table.AddColumn in your Power Query M code.

    • ldwf's avatar
      ldwf
      Helper V

      Some of the DAX code we build is quite extensive, i.e, like 50 or more lines for just one calculated column.  If I want to clone these calculated columns, do I need to rebuild all the DAX formulas in Power Query M code?

      • lbendlin's avatar
        lbendlin
        Super User

        Absolutely. Having these complex calculated columns in the first place is a design red flag. Don't forget -they eat up space AND compute when they are calculated.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi ldwf 

     

    In Power BI dataflows, you can't create calculated fields using DAX directly as you do in Power BI Desktop. Dataflows use Power Query, which relies on M code for transformations and calculations

    But unfortunately, there isn't a direct tool to convert DAX to M code.

     

    Just as lbendlin posted that you'd better off re-implementing the business logic.

     

    Otherwise you can only use M-code to rewrite your calculated column as a custom column manually, I believe this is a huge amount of work. 

    Solved: Creating a calculated table in PowerBI Service dat... - Microsoft Fabric Community

     

    Best Regards

    Zhengdong Xu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.