Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameter changeValueAsync with percentages expects comma instead of point #104

Closed
tjallingt opened this issue Apr 12, 2018 · 7 comments
Closed
Labels
Logged Internally Issue which has been logged internally at Tableau

Comments

@tjallingt
Copy link

Reproducable example: try the Parameter.changeValueAsync method on the Superstore workbook to change the "Churn rate" parameter.

parameter.changeValueAsync(0.1); // 25%
parameter.changeValueAsync("0.1"); // 25%
parameter.changeValueAsync("0,1"); // 10%

This is especially confusing because it will return DataValue.value === "0.1" (point not comma 😖)

@benlower benlower added the Logged Internally Issue which has been logged internally at Tableau label Apr 23, 2018
@benlower
Copy link
Contributor

We're taking a look at this.

@tjallingt
Copy link
Author

Great to hear! This would allow me to strip a really ugly hack out of my extension code 😅

@Kovner
Copy link
Contributor

Kovner commented May 1, 2018

@tjallingt What is the locale of you Desktop instance set to? If it's not en-US, can you try reproducing with it set to en-US?

@tjallingt
Copy link
Author

My locale is set to en-US:

capture2

@Kovner
Copy link
Contributor

Kovner commented May 18, 2018

OK, It does have to do with your machine's locale and therefore how Tableau is displaying the parameter. With my os language set to English, I could not reproduce this ('0.1' showed 10.00% in the param), but then I changed my os language to French and that changed how Tableau was displaying the value in the param to 10,00% (similar to your screenshot). Now, I have to pass in '0,1' for it to work and '0.1' throws an error.

So in a way that feels consistent, but I also repro'd what you said about param.currentValue returning '0.1' even when the param is using commas for delimeters. So that is inconsistent and we also have to make sure the allowableValues gives you the right info to know what to pass in.

Thanks for letting us know about this.

@tjallingt
Copy link
Author

tjallingt commented May 21, 2018

Hey @Kovner thanks for your response, great to hear you figured out what is causing this strange behaviour 👍

So i see two bugs and a feature request here, the bugs (as i see it):

  • the allowableValues is giving me a value that does not match what changeValueAsync expects
  • the locale returned by tableau is somehow not the locale that is actually used for localisation of the data (if my locale was causing this problem why did tableau report my locale to be en-us?)

The feature request concerns the fact that obviously string representations of numeric values are not perfect (especially when casting is made difficult by different localisations of the same value). It would be great if allowableValues and changeValueAsync would just use floating point numbers for percentages.

I'm assuming the reason the extension API is spitting out strings is somehow tied to how Tableau is handling this data internally so there might not be a quick fix for that but perhaps the extension api could supply us with a localisation method that takes care of correctly formatting percentages for changeValueAsync (and all the other places values are expected to be localised of course)

@Kovner
Copy link
Contributor

Kovner commented May 21, 2018

Yep, I agree with all of that. We'll look into it soon, but I'm not sure whether any related fixes will be in v1 of Extensions API or post-v1. And if it's post-v1, we'll have to be sure to not make breaking changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Logged Internally Issue which has been logged internally at Tableau
Projects
None yet
Development

No branches or pull requests

3 participants