Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hi all, please is it possible to call a Varable in a Html code, if so how please
Solved! Go to Solution.
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>
"
This is known as concatenation in DAX. Here's some further reading on how you can approach it.
Regards,
Daniel
Proud to be a Super User!
On how to ask a technical question, if you really want an answer (courtesy of SQLBI)
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>
"
This is known as concatenation in DAX. Here's some further reading on how you can approach it.
Regards,
Daniel
Proud to be a Super User!
On how to ask a technical question, if you really want an answer (courtesy of SQLBI)
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
8 | |
7 | |
2 | |
2 | |
2 |
User | Count |
---|---|
6 | |
5 | |
4 | |
4 | |
4 |