Deep dive into DAX query view for web | Microsoft Power BI Blog


We are excited to announce you can now write DAX queries with DAX query view for web from published semantic models in the workspace.

In Power BI, DAX formulas are used to define different types of calculations such as measures or calculated columns. DAX queries, on the other hand, can be used to return data from the semantic model. DAX queries are like SQL queries in that they can show your data by specified group by columns and aggregations. For DAX queries, this includes the measures already defined in your model and you can define additional query scoped measures, if needed.

To write DAX queries in DAX query view in the web, there is a workspace setting that needs to be enabled and there are two entry points.

  1. DAX query view in the web needs the User can edit data models in the Power BI service (preview) turned on. This is found in Workspace settings > Power BI > General. DAX query view does allow some paths to update or add measures.
  2. Click on Write DAX queries from the right-click, or context menu, on a semantic model in the workspace.
  3. Click on Write DAX queries from the top to the semantic model details page.

And now you can write DAX queries using the DAX query view in the web.

DAX query view is already available in Power BI Desktop, and most of the features are the same for web, with a few differences.

  • DAX queries are discarded on close. DAX queries in Power BI Desktop are saved to the model and a semantic model may have DAX queries already saved in the model. DAX query view in the web currently will not display any previously saved DAX queries that may exist in the semantic model, and queries created in the web are not kept after you close the browser.
  • Write DAX queries requires write permission on the semantic model. Workspace viewers will not be able to write DAX queries using this web experience in this milestone. Future updates will allow viewers to write DAX queries, but for now they will still have to use Power BI Desktop with live connection to the semantic model.

DAX query view in web can be used on semantic models in import, DirectQuery, and Direct Lake mode.

Microsoft Fabric customers already taking advantage of the new Direct Lake mode for Power BI now have the new measure editing capabilities of DAX query view available them through this web experience.

Here is an example of using DAX query view in the web to add measures to a semantic model in Direct Lake mode. This example with work with Power BI semantic model in import or DirectQuery storage modes too.

  1. This demo semantic model has one billion (1,000,000,000) orders in the Sales fact table, one for each row. I already have a measure called Avg Profit Per Order which I can use the Quick queries in the context menu to Define with references and evaluate to see not only this measures DAX formula, but also the measures referenced in this measure with their DAX formulas.
  2. DAX query view converts these model measures to query scoped measures, and I can not only see all 5 of these measures used to calculate Avg Profit Per Order, but I can also make changes. These changes can be seen when I Run the DAX query but will not impact the existing measures in the model until I am ready to convert them back to model measures.
  3. I want to create a new measure to show the Avg Sales Per Order. This will be the same DAX pattern as Avg Profit Per Order so I want to first copy it then modify it to be for Sales. I can use the Command palette to find the shortcut to Copy Line Down to help me with this task.
  4. Now I only have to make two updates, one to change the name and the second to update [Profit] to [Sales]. When I am done, I can see this measure does not already exist in the model because of the CodeLens action text that shows between line 6 and 7 prompting me to Update model: Add new measure.
  5. I can test out this additional measure by clicking the Run and I see the result is as expected. I can also take the opportunity to improve the readability of all these measures with Format query ribbon button. I am happy with all the changes I have made and now I can use the Update model with changes (6) button to see I have 6 measure expressions that differ from the model expressions and to update them in a single click.
  6. After clicking Update model with changes, I can see the new measure in the Model Explorer of the Data pane to the right of the DAX editor. And I can remove the DEFINE block and run the DAX query again to see the results still.
  7. Without the DEFINE block I can always see the DAX formula of any measure being used in the query by hovering over it with my curser. When there is a DEFINE block for this measure, it will show both model DAX formula and query DAX formula, if they are different, too. If a measure description is provided, this shows as well.

And the Fabric Copilot to help write and explain DAX queries is also available in DAX query view in the web.

Learn more about DAX queries, DAX query view, Copilot to write and explain DAX queries, and any other limitations with DAX query view in web with these resources.

And keep letting us know your feedback with the Share feedback button in DAX query view. All the feedback so far has helped us greatly to keep delivering updates and bug fixes to DAX query view!



Source link

Be the first to comment

Leave a Reply

Your email address will not be published.


*