Update August 2024
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.
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 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.
Recommended by LinkedIn
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!