Dashboards & Visualizations

How to display store number with leading zeros in single panel in dashboard.

kumar_pashupati
New Member

I am trying to display the store number under single-panel in dashboard . But it is truncting the leading zeros store numbers.
Example: I want to display store number 002346 as it is. But it is displaying as 2346 in the dashboard.We have 6 digit store number. Please help me.

<single>

        |inputlookup store_data_api.csv |where like( store_number,"$storeList$")        

      | fields store_number
      </query>

</single>

It is displaying 2346 instead of 002346.

0 Karma

vnravikumar
Champion

Hi

Give a try

<dashboard>
  <label>single</label>
  <row>
    <panel>
      <single>
        <search>
          <query>|makeresults |eval test=0123</query>
          <earliest>-24h@h</earliest>
          <latest>now</latest>
          <done>
            <eval token="unit">case(len($result.test$) == 3, "000",len($result.test$) == 4, "00",len($result.test$) == 5, "0",len($result.test$) == 2, "0000",len($result.test$) == 1, "00000",len($result.test$) == 6, "")</eval>
          </done>
        </search>
        <option name="drilldown">none</option>
        <option name="rangeColors">["0x53a051","0x0877a6","0xf8be34","0xf1813f","0xdc4e41"]</option>
        <option name="unit">$unit$</option>
        <option name="unitPosition">before</option>
        <option name="useThousandSeparators">0</option>
      </single>
    </panel>
  </row>
</dashboard>
0 Karma

kumar_pashupati
New Member

Hi @somesoni2 @niketnilay and @Vijeta

Thanks for sharing your valuable suggestion.
Putting 00 in unit will be fail for store numbers having 5 digits.It should be dynamic.
Finally I got the solution and sharing my answer so that other will take help of this..

I just use the concept of unicode punctuation..I have store number with appending zero e.g.001234.But, in a single panel it is displaying as 1234. So what I did was that use the ‪

        |inputlookup store_data_api.csv |where like( store_number,"$storeList$")
        | eval field="&#8234;"+ store_number
        | fields field

Now the whole stroe number is converted into string(do not use tostring as it is not going to help) and concatenate with unicode character. Thats it.

Thanks everyone.

0 Karma

niketn
Legend

You can also use <html> <panel> instead of single value visualization and use the Search Event Handler to pass the store_number as token to the html panel. Refer to the following run anywhere example. The Independent search needs to be replaced with your search query.

<dashboard>
  <label>HTML Panel Single Result</label>
  <!-- Your Search Goes Here -->
  <!-- Following is a run anywhere independent search which returns static Store # 002346 -->
  <search>
    <query>| makeresults
| fields - _time
| eval store_number="002346"</query>
    <earliest>-24h@h</earliest>
    <latest>now</latest>
    <sampleRatio>1</sampleRatio>
    <progress>
      <set token="tokStoreNumber">$result.store_number$</set>
    </progress>
  </search>
  <row>
    <panel id="panelSingleStoreNum">
      <html>
        <style>
          #panelSingleStoreNum .dashboard-panel{
            height: 100px;
          }
          #panelSingleStoreNum div div.single-result{
            text-align: center;
            letter-spacing: -0.02em;
            font-weight: bold;
            fill: rgb(51, 51, 51);
            opacity: 1;
            font-size: 250%;
            text-align: center;
            padding-top: 30px;
          }
        </style>
        <div>
          <div class="single-result">$tokStoreNumber$</div>
        </div>
      </html>
    </panel>
  </row>
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

Vijeta
Influencer

@kumar_pashupati - In the single visuallization UI, click on format,->Number Format , give Unit as 00 and Unit Position as Before. This will make a 4 digit result look as 6 digit.

0 Karma

kumar_pashupati
New Member

Kindly help me

0 Karma

somesoni2
SplunkTrust
SplunkTrust

Going by the Splunk documentation for single value visualization, this visualization expects data to be in number to show trend/color. That's why it's converting your string store_number to number format and removing those leading zero's. Would having a prefix (say Store#:) before the value would be acceptable to you? If yes, you do an eval to append that to your store_number field.

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...