{"id":41862,"date":"2025-07-25T14:52:36","date_gmt":"2025-07-25T09:22:36","guid":{"rendered":"https:\/\/www.inogic.com\/blog\/?p=41862"},"modified":"2025-07-25T17:09:48","modified_gmt":"2025-07-25T11:39:48","slug":"enhance-power-bi-reports-with-automatic-language-detection-using-python","status":"publish","type":"post","link":"https:\/\/www.inogic.com\/blog\/2025\/07\/enhance-power-bi-reports-with-automatic-language-detection-using-python\/","title":{"rendered":"Enhance Power BI Reports with Automatic Language Detection Using Python"},"content":{"rendered":"<p><img decoding=\"async\" class=\"alignnone size-full wp-image-41890\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/Enhance-Power-BI-Reports-with-Automatic-Language-Detection-Using-Python.png\" alt=\"Enhance Power BI Reports with Automatic Language Detection Using Python\" width=\"1925\" height=\"1100\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/Enhance-Power-BI-Reports-with-Automatic-Language-Detection-Using-Python.png 1925w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/Enhance-Power-BI-Reports-with-Automatic-Language-Detection-Using-Python-300x171.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/Enhance-Power-BI-Reports-with-Automatic-Language-Detection-Using-Python-1024x585.png 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/Enhance-Power-BI-Reports-with-Automatic-Language-Detection-Using-Python-768x439.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/Enhance-Power-BI-Reports-with-Automatic-Language-Detection-Using-Python-1536x878.png 1536w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/Enhance-Power-BI-Reports-with-Automatic-Language-Detection-Using-Python-660x377.png 660w\" sizes=\"(max-width: 1925px) 100vw, 1925px\" \/><\/p>\n<p>In a world where businesses interact with customers across multiple regions and languages, analyzing multilingual content is no longer optional; it\u2019s essential. Whether you\u2019re collecting feedback, managing leads, or reviewing support tickets, knowing the language of your data opens doors to better automation, routing, and personalization.<\/p>\n<p>As we know, Power BI itself does not have inbuilt functions to detect the language, but this can be achieved with the help of Python Scripting.<\/p>\n<p>This blog walks you through how to implement <strong>Automatic Language Detection<\/strong> inside Power BI using Python scripting with no external services required. We&#8217;ll consider the real-world scenario below to showcase the above functionality:<\/p>\n<p>Many CRM systems like <strong>Dynamics 365 Sales<\/strong> collect lead descriptions, inquiries, or comments from global web forms, campaigns, and events. This information is collected in different languages.<\/p>\n<p>Here&#8217;s what you can do with <strong>language detection in Power BI<\/strong>:<\/p>\n<table>\n<thead>\n<tr>\n<td><strong>Capability<\/strong><\/td>\n<td><strong>Scenario<\/strong><\/td>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Auto-assign leads by language<\/td>\n<td>Route Spanish inquiries to Spanish-speaking sales reps<\/td>\n<\/tr>\n<tr>\n<td>Analyze conversion by language<\/td>\n<td>Discover which regions or languages convert best<\/td>\n<\/tr>\n<tr>\n<td>Localize engagement strategies<\/td>\n<td>Adapt sales scripts and materials to match lead language<\/td>\n<\/tr>\n<tr>\n<td>Filter dashboards intelligently<\/td>\n<td>Allow sales managers to analyze leads by language group<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p>Follow the below pre-requisites steps to <strong>Automatically detect the language using Power Bi<\/strong>:<\/p>\n<ul>\n<li>Click on the setting icons as shown below:<\/li>\n<\/ul>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-41863\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/1Automatic-Language-Detection-Using-Python.png\" alt=\"Automatic Language Detection Using Python\" width=\"1152\" height=\"489\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/1Automatic-Language-Detection-Using-Python.png 1152w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/1Automatic-Language-Detection-Using-Python-300x127.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/1Automatic-Language-Detection-Using-Python-1024x435.png 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/1Automatic-Language-Detection-Using-Python-768x326.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/1Automatic-Language-Detection-Using-Python-660x280.png 660w\" sizes=\"(max-width: 1152px) 100vw, 1152px\" \/><\/p>\n<ul>\n<li>Go to Python Scripting and add the Python directory. If Python is not installed, then install Python from <a href=\"https:\/\/www.python.org\/\" target=\"_blank\" rel=\"noopener\">Welcome to Python.org<\/a> and add the directory. Once done, click ok.<\/li>\n<\/ul>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-41864\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/2Automatic-Language-Detection-Using-Python.png\" alt=\"Automatic Language Detection Using Python\" width=\"1363\" height=\"618\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/2Automatic-Language-Detection-Using-Python.png 1363w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/2Automatic-Language-Detection-Using-Python-300x136.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/2Automatic-Language-Detection-Using-Python-1024x464.png 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/2Automatic-Language-Detection-Using-Python-768x348.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/2Automatic-Language-Detection-Using-Python-660x299.png 660w\" sizes=\"(max-width: 1363px) 100vw, 1363px\" \/><\/p>\n<p>Once the pre-requisite steps are done, follow the below steps to <strong>Automatically detect the language using Power Bi:<\/strong><\/p>\n<ul>\n<li>Open Power BI desktop and create a blank report.<\/li>\n<li>Click on the Dataverse connector, select the Leads table from your environment, and then click on Transform Data to proceed with data shaping.<\/li>\n<li>Do required transformations like selecting the columns, remove duplicates and other transformations.<\/li>\n<\/ul>\n<p>Once done, click on the Run Python Scripts option.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-41865\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/3Automatic-Language-Detection-Using-Python.png\" alt=\"Automatic Language Detection Using Python\" width=\"1370\" height=\"524\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/3Automatic-Language-Detection-Using-Python.png 1370w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/3Automatic-Language-Detection-Using-Python-300x115.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/3Automatic-Language-Detection-Using-Python-1024x392.png 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/3Automatic-Language-Detection-Using-Python-768x294.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/3Automatic-Language-Detection-Using-Python-660x252.png 660w\" sizes=\"(max-width: 1370px) 100vw, 1370px\" \/><\/p>\n<ul>\n<li>Paste the below code in the Python script and then press ok.<\/li>\n<\/ul>\n<p># &#8216;dataset&#8217; holds the input data for this script<\/p>\n<pre class=\"lang:css gutter:true start:1\">from langdetect import detect, DetectorFactory\r\n\r\nimport pycountry\r\n\r\nDetectorFactory.seed = 0\u00a0 # Ensures consistent results\r\n\r\ndef detect_language(text):\r\n\r\ntry:\r\n\r\nlang_code = detect(str(text))\u00a0 # Convert to string to avoid errors\r\n\r\nlanguage = pycountry.languages.get(alpha_2=lang_code)\u00a0 # Get full language name\r\n\r\nreturn language.name if language else \"Unknown\"\r\n\r\nexcept:\r\n\r\nreturn \"Unknown\"\r\n\r\ndataset[\"Language\"] = dataset[\"subject\"].astype(str).apply(detect_language)<\/pre>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-41866\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/4Automatic-Language-Detection-Using-Python.png\" alt=\"Automatic Language Detection Using Python\" width=\"1369\" height=\"603\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/4Automatic-Language-Detection-Using-Python.png 1369w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/4Automatic-Language-Detection-Using-Python-300x132.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/4Automatic-Language-Detection-Using-Python-1024x451.png 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/4Automatic-Language-Detection-Using-Python-768x338.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/4Automatic-Language-Detection-Using-Python-660x291.png 660w\" sizes=\"(max-width: 1369px) 100vw, 1369px\" \/><\/p>\n<ul>\n<li>Click on the expand option and select the fields that are needed, as shown below:<\/li>\n<\/ul>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-41867\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/5Automatic-Language-Detection-Using-Python.png\" alt=\"Automatic Language Detection Using Python\" width=\"1369\" height=\"541\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/5Automatic-Language-Detection-Using-Python.png 1369w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/5Automatic-Language-Detection-Using-Python-300x119.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/5Automatic-Language-Detection-Using-Python-1024x405.png 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/5Automatic-Language-Detection-Using-Python-768x303.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/5Automatic-Language-Detection-Using-Python-660x261.png 660w\" sizes=\"(max-width: 1369px) 100vw, 1369px\" \/><\/p>\n<ul>\n<li>Now, a language column is created that detects the language of the subject.<\/li>\n<\/ul>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-41868\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/6Automatic-Language-Detection-Using-Python.png\" alt=\"Automatic Language Detection Using Python\" width=\"1368\" height=\"523\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/6Automatic-Language-Detection-Using-Python.png 1368w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/6Automatic-Language-Detection-Using-Python-300x115.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/6Automatic-Language-Detection-Using-Python-1024x391.png 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/6Automatic-Language-Detection-Using-Python-768x294.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/6Automatic-Language-Detection-Using-Python-660x252.png 660w\" sizes=\"(max-width: 1368px) 100vw, 1368px\" \/><\/p>\n<p>Since all the transformations are completed, we can now proceed with creating the report. We have created the report below for our scenario:<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-41869\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/7Automatic-Language-Detection-Using-Python.png\" alt=\"Automatic Language Detection Using Python\" width=\"1008\" height=\"617\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/7Automatic-Language-Detection-Using-Python.png 1008w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/7Automatic-Language-Detection-Using-Python-300x184.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/7Automatic-Language-Detection-Using-Python-768x470.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/7Automatic-Language-Detection-Using-Python-660x404.png 660w\" sizes=\"(max-width: 1008px) 100vw, 1008px\" \/><\/p>\n<p>Now, based on the above report, we can achieve the following:<\/p>\n<ul>\n<li>Filter dashboards intelligently based on languages.<\/li>\n<li>The sales manager can assign a lead to the appropriate salesperson. For example, Route Spanish inquiries to Spanish-speaking sales reps.<\/li>\n<li>Can do more analysis by adding bar charts. For example, discover which regions or languages convert best.<\/li>\n<\/ul>\n<p><strong>Conclusion:<\/strong><\/p>\n<p>By combining <strong>Python and Power BI<\/strong>, you can add a powerful layer of intelligence to your lead analysis, helping sales teams become more efficient, more localized, and more responsive. Language detection is just one example of how you can bring advanced automation into everyday sales workflows.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In a world where businesses interact with customers across multiple regions and languages, analyzing multilingual content is no longer optional; it\u2019s essential. Whether you\u2019re collecting feedback, managing leads, or reviewing support tickets, knowing the language of your data opens doors to better automation, routing, and personalization. As we know, Power BI itself does not have\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.inogic.com\/blog\/2025\/07\/enhance-power-bi-reports-with-automatic-language-detection-using-python\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":15,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[45,2361],"tags":[2912,3197],"class_list":["post-41862","post","type-post","status-publish","format-standard","hentry","category-power-bi","category-technical","tag-power-bi-reports","tag-python"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/41862","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/users\/15"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/comments?post=41862"}],"version-history":[{"count":0,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/41862\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media?parent=41862"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/categories?post=41862"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/tags?post=41862"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}