# How to use if else condition in postman visualizer

**URL:** <https://community.postman.com/t/how-to-use-if-else-condition-in-postman-visualizer/41526>\
**Category:** Help Hub\
**Tags:** tests, postman, visualizer, if-else\
**Created:** [November 28, 2022, 2:36pm UTC](https://community.postman.com/t/how-to-use-if-else-condition-in-postman-visualizer/41526 "2022-11-28T14:36:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![science-specialist-3](https://avatars.discourse-cdn.com/v4/letter/s/7993a0/32.png) [@science-specialist-3](https://community.postman.com/u/science-specialist-3)\
**Post date:** [November 28, 2022, 2:36pm UTC](https://community.postman.com/t/how-to-use-if-else-condition-in-postman-visualizer/41526/1 "2022-11-28T14:36:25Z")

</div>

Hi All,

Actually i want to write if else condition in my table data tag  
the condition is such that if key value is null or document don’t have key  
in the table it should show null.

Here testOne and test are column in my documents  
My code in test  
var template = `

```
<table bgcolor="white">
    <tr>
        <th>Title</th>
        <th>Year</th>
        <th>IMDB Rating</th>
        <th>Awards Wins<th>
        <th>test<th>
        <th>testOne<th>
    </tr>

    {{#each response}}
        <tr>
            <td>{{title}}</td>
            <td>{{year}}</td>
            <td>{{imdb.rating}}</td>
            <td>{{awards.wins}}</td>
            <td>{{test}}<td>
            if ({{testOne}}) {
                return (
                <td>{{testOne}}</td>
                ) 
            } else {
                return (
                <td>null</td>
                )
            }    
        </tr>
    {{/each}}
</table>

```

`;

// Set visualizer  
pm.visualizer.set(template, {  
// Pass the response body parsed as JSON as `data`  
response: pm.response.json().documents  
});
