Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
1 year ago
Solved

How to sum a column when pulling data from semantic model?

Hi   I created a simple 2 column table on my powerbi desktop using "Table" in the visualizations.   I dragged in a measure column [ sale_date ] and a dimension column [widgets]. The dimension co...
  • DataNinja777's avatar
    1 year ago

    Hi Anonymous ,

     

    If you're working in Power BI Desktop and pulling data from a semantic model (such as a published dataset or Analysis Services), then your ability to write DAX measures depends on whether you're allowed to extend the model. If you're in a pure live connection mode, Power BI won’t let you create new measures unless you're using DirectQuery for Power BI datasets (composite models). If that’s enabled, click “Make changes to this model” when prompted, and you’ll be able to create a new measure.

    To create a DAX measure that sums the [Widgets] column, you can write:

    Total Widgets = SUM('YourTableName'[Widgets])
    

    Replace 'YourTableName' with the actual name of your table in the model. If [Widgets] is already a measure and not a raw column, don’t try to wrap it in SUM() again—just use it directly. If your model doesn’t support adding measures, you won’t see the option to create one, and you’ll need to enable composite model mode via File > Options > Preview features > DirectQuery for Power BI datasets and restart Power BI. Once done, you can add your own measures and use them in visuals like any other field.

     

    Best regards,