Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
mkjit256
Advocate I
Advocate I

Is there a visual that can display formatted Dax Measure Expressions

Hello,

I am trying to build a report that display the measure dax code that i have written in other reports. I am able to get the text of the  measure expressions from a power bi template file. What i am looking for is to see if there is any custom visual that can display the dax measures in a good looking format?

Till now i am visualizing the measure's text in a column in a table visual, but it is so difficult to read.

3 REPLIES 3
lbendlin
Super User
Super User

you can call the DAXFormatter.com API.

Thanks for your reply,

can you please elaborate a little bit more?

What i understood is that you are suggesting that i call the Daxformatter api, to generate a new formatted column out of my raw dax measure, right?

Trying to invoke that column but getting the following error:

mkjit256_0-1683116270626.png

 

 

You seem to be trying to do this in Power Query?  Is that where your DAX queries are stored?

 

This is what the general process would look like. NOTE:  Check the API usage conditions before proceeding!

 

 

 

let
    Source = #table({"Raw"},{{"Show = 
var m = max(Dates[Date])
var d = CALCULATE(max('Table'[Transaction Date]),ALLEXCEPT('Table','Table'[Customerid]),'Table'[Transaction Date]<=m && 'Table'[Transaction Date]>= EDATE(m,-3))
return if (SELECTEDVALUE('Table'[Transaction Date])=d,1,0)"}}),
    #"Added Custom" = Table.AddColumn(Source, "Link", each "https://www.daxformatter.com/?embed=1&fx=" & Uri.EscapeDataString([Raw])),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Result", each Web.BrowserContents([Link],[WaitFor = [Selector = "div.result"]])),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Added Custom1", "Result", Splitter.SplitTextByEachDelimiter({"<div class=""result"">"}, QuoteStyle.None, false), {"Result.1", "Result.2"}),
    #"Split Column by Delimiter1" = Table.SplitColumn(#"Split Column by Delimiter", "Result.2", Splitter.SplitTextByEachDelimiter({"</div"}, QuoteStyle.Csv, false), {"Formatted HTML", "Result.2.2"}),
    #"Removed Other Columns" = Table.SelectColumns(#"Split Column by Delimiter1",{"Raw", "Formatted HTML"})
in
    #"Removed Other Columns"

 

and then displayed in a HTML5 viewer visual:

lbendlin_0-1683119352472.png

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.