Supplies are limited. Contact info@espc.tech right away to save your spot before the conference sells out.
Get your discountScore big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount
Hi,
I have a table with "production functions" in different languages.
I would like to get the "production functions" in the language that is selected in the slicer or if no slicer value is slected, use the USERCULTURE language.
This is my measure:
SafetyCodes_Language =
var SelectedLanguage = SWITCH(TRUE(),
SELECTEDVALUE('Safety codes (2)'[Language])="en","en",
SELECTEDVALUE('Safety codes (2)'[Language])="fr","fr",
SELECTEDVALUE('Safety codes (2)'[Language])="nl","nl",
SELECTEDVALUE('Safety codes (2)'[Language])="pl","pl",
SELECTEDVALUE('Safety codes (2)'[Language])="ru","ru",
LEFT(USERCULTURE(),2)
)
return CALCULATE(DISTINCTCOUNT('info_HGR unpivoted'[Index]),'Safety codes (2)'[Language]=SelectedLanguage)
If a language is selected in the slicer, the filtering is done correctly:
Without selecting any slicervalue, all translations are shown:
When changing the measure to get the USERCULTURE directly, the filtering is also done correctly:
SafetyCodes_Language =
var SelectedLanguage = LEFT(USERCULTURE(),2)
return CALCULATE(DISTINCTCOUNT('info_HGR unpivoted'[Index]),'Safety codes (2)'[Language]=SelectedLanguage)
I don't see why the first measure is not working as expected.
Solved! Go to Solution.
I assume the y axis is from the 'Safety codes (2)' table? In which case there is a single value per row. Try
SafetyCodes_Language =
IF(
ISFILTERED( SELECTEDVALUE('Safety codes (2)'[Language]) ),
// IF filtered show all selected languages
DISTINCTCOUNT( 'info_HGR unpivoted'[Index] ),
// If no filter use user's language
CALCULATE(
DISTINCTCOUNT('info_HGR unpivoted'[Index]),
TREATAS'( { LEFT(USERCULTURE(),2) }, 'Safety codes (2)'[Language] )
)
)
Awesome! Thanks @Deku , it's working now. Made a small adaptation to your code:
SafetyCodes_Language =
IF(
ISFILTERED('Safety codes (2)'[Language]),
// IF filtered show all selected languages
DISTINCTCOUNT( 'info_HGR unpivoted'[Index] ),
// If no filter use user's language
CALCULATE(DISTINCTCOUNT('info_HGR unpivoted'[Index]),'Safety codes (2)'[Language]=LEFT(USERCULTURE(),2))
)
Thanks for the quick support.
I assume the y axis is from the 'Safety codes (2)' table? In which case there is a single value per row. Try
SafetyCodes_Language =
IF(
ISFILTERED( SELECTEDVALUE('Safety codes (2)'[Language]) ),
// IF filtered show all selected languages
DISTINCTCOUNT( 'info_HGR unpivoted'[Index] ),
// If no filter use user's language
CALCULATE(
DISTINCTCOUNT('info_HGR unpivoted'[Index]),
TREATAS'( { LEFT(USERCULTURE(),2) }, 'Safety codes (2)'[Language] )
)
)