cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
Janewhite
Frequent Visitor

HTML

Hi all, please is it possible to call a Varable in a Html code, if so how please

Measure 3 =
VAR name_ = USERNAME()

return
"
<!DOCTYPE html>
<html>
<title>W3.CSS</title>
<meta name=""viewport"" content=""width=device-width, initial-scale=1"">
<link rel=""stylesheet"" href=""https://www.w3schools.com/w3css/4/w3.css"">
<body>

<div class=""w3-container"">
  <h2>Card Content</h2>
  <p>Add containers inside the card to create different sections:</p>
 
  <div class=""w3-card-4"" style=""width:50%;"">
    <header class=""w3-container w3-blue"">
      <h1>Header</h1>
    </header>

    <div class=""w3-container"">
      name_
    </div>

    <footer class=""w3-container w3-blue"">
      <h5>Footer</h5>
    </footer>
  </div>
</div>

</body>
</html>

"





Janewhite_0-1692111667299.png

Janewhite_1-1692111685344.png

 

 

1 ACCEPTED SOLUTION
dm-p
Super User
Super User

Hi @Janewhite,

To include a variable, you terminate the HTML with a double-quote where you want to add it. You then use an ampersand and the variable name, followed by a trailing ampersand and a double quote to resume the HTML, e.g.:

Measure 3 = 
VAR name_ = USERNAME()

return
"
<!DOCTYPE html>
<html>
<title>W3.CSS</title>
<meta name=""viewport"" content=""width=device-width, initial-scale=1"">
<link rel=""stylesheet"" href=""https://www.w3schools.com/w3css/4/w3.css"">
<body>

<div class=""w3-container"">
  <h2>Card Content</h2>
  <p>Add containers inside the card to create different sections:</p>
 
  <div class=""w3-card-4"" style=""width:50%;"">
    <header class=""w3-container w3-blue"">
      <h1>Header</h1>
    </header>

    <div class=""w3-container"">
      " & name_ & "
    </div>

    <footer class=""w3-container w3-blue"">
      <h5>Footer</h5>
    </footer>
  </div>
</div>

</body>
</html>
"

 

dmp_0-1692149654619.png

 

This is known as concatenation in DAX. Here's some further reading on how you can approach it.

 

Regards,

 

Daniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


My course: Introduction to Developing Power BI Visuals


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




View solution in original post

1 REPLY 1
dm-p
Super User
Super User

Hi @Janewhite,

To include a variable, you terminate the HTML with a double-quote where you want to add it. You then use an ampersand and the variable name, followed by a trailing ampersand and a double quote to resume the HTML, e.g.:

Measure 3 = 
VAR name_ = USERNAME()

return
"
<!DOCTYPE html>
<html>
<title>W3.CSS</title>
<meta name=""viewport"" content=""width=device-width, initial-scale=1"">
<link rel=""stylesheet"" href=""https://www.w3schools.com/w3css/4/w3.css"">
<body>

<div class=""w3-container"">
  <h2>Card Content</h2>
  <p>Add containers inside the card to create different sections:</p>
 
  <div class=""w3-card-4"" style=""width:50%;"">
    <header class=""w3-container w3-blue"">
      <h1>Header</h1>
    </header>

    <div class=""w3-container"">
      " & name_ & "
    </div>

    <footer class=""w3-container w3-blue"">
      <h5>Footer</h5>
    </footer>
  </div>
</div>

</body>
</html>
"

 

dmp_0-1692149654619.png

 

This is known as concatenation in DAX. Here's some further reading on how you can approach it.

 

Regards,

 

Daniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


My course: Introduction to Developing Power BI Visuals


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors