Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Boeboey
Frequent Visitor

Filtering on USERCULTURE() if no language has been selected in slicer

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:

2025-03-25 11 13 34.png

Without selecting any slicervalue, all translations are shown:

2025-03-25 11 13 42.png

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)

2025-03-25 11 15 45.png

 

I don't see why the first measure is not working as expected.

1 ACCEPTED SOLUTION
Deku
Super User
Super User

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] ) 
   )
)

 


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

View solution in original post

2 REPLIES 2
Boeboey
Frequent Visitor

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.

Deku
Super User
Super User

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] ) 
   )
)

 


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors