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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
kenven01
Helper I
Helper I

How to get key ID from instead text from SAP BW query.

Hi experts,

    I have  SAP BW (7.3) Bex Query as a data source for my BI desktop report.

    However, the keys like month, plant and materials number are can only be displayed as text instead of key ID.

    For example, data field MONTH(0calmonth in BW) is displed as 'JAN 2024' ,

    finding no way to display as '202401'.  Actually both  '202401' and 'JAN 2024' can be displayed in BW query.

    Anyone can help with this ? 

 

    Thank you in advance.

 

  

17 REPLIES 17
v-tangjie-msft
Community Support
Community Support

Hi @kenven01 ,

 

According to your description, here are my steps you can follow as a solution.

(1)Click "transform data" to enter power query --> split Month column by space.

vtangjiemsft_0-1714010731646.pngvtangjiemsft_1-1714010755753.png

(2)Add conditional columns.

vtangjiemsft_2-1714010937355.png

vtangjiemsft_3-1714011120828.png

(3)Merge the columns [Month.2], [Custom.1], [Custom]. Note that columns are selected in merge order. -->Modifies the data type of the column.

vtangjiemsft_4-1714011226605.png

vtangjiemsft_5-1714011365017.png

Modify the merge column name and delete the [Month.1] column and then the result is as follows.

vtangjiemsft_6-1714011481355.png

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

Hi Neeko,

    Firstly thank you for your quick response.

    I also tried to do the same things as you post, however,

    the transformation data function is disabled/greyed out for my case, which the data soucre is coming

    from SAP BW query thru SAP connector (ver 3.0) and using DirectQuery rather than import method to

   open data. Only report view is there, no table and model view for my case.

   So, I'm wondering some PBI features on data navigation are restricted for SAP BW query.

    I already use the latest PBI desttop version that is released in this month.

Hi @kenven01 ,

 

Please try creating a calculated column.

New month = 
var _a= RIGHT([Month],4) 
var _b=SWITCH(TRUE(),
CONTAINSSTRING([Month],"JAN"),"01",
CONTAINSSTRING([Month],"FEB"),"02",
CONTAINSSTRING([Month],"MAR"),"03",
CONTAINSSTRING([Month],"APR"),"04",
CONTAINSSTRING([Month],"MAY"),"05",
CONTAINSSTRING([Month],"JUN"),"06",
CONTAINSSTRING([Month],"JUL"),"07",
CONTAINSSTRING([Month],"AUG"),"08",
CONTAINSSTRING([Month],"SEP"),"09",
CONTAINSSTRING([Month],"OCT"),"10",
CONTAINSSTRING([Month],"NOV"),"11",
CONTAINSSTRING([Month],"DEC"),"12")
RETURN INT(_a & _b)

vtangjiemsft_0-1714029781721.png

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

Hi Neeko,

 

    The data field 'Month' in query is viewed as text table field, not key figures.

    So I have to change '[Month]' to '(Month)' in DAX codes as below.

    But it prompts me with error 'The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value'. 

   So the way still doesn't work.

--------- Codes ---------------------------------------------

New month =
var _a= RIGHT((Month),4)
var _b=SWITCH(TRUE(),
CONTAINSSTRING((Month),"JAN"),"01",
CONTAINSSTRING((Month),"FEB"),"02",
CONTAINSSTRING((Month),"MAR"),"03",
CONTAINSSTRING((Month),"APR"),"04",
CONTAINSSTRING((Month),"MAY"),"05",
CONTAINSSTRING((Month),"JUN"),"06",
CONTAINSSTRING((Month),"JUL"),"07",
CONTAINSSTRING((Month),"AUG"),"08",
CONTAINSSTRING((Month),"SEP"),"09",
CONTAINSSTRING((Month),"OCT"),"10",
CONTAINSSTRING((Month),"NOV"),"11",
CONTAINSSTRING((Month),"DEC"),"12")
RETURN INT(_a & _b)

Please see the hot screenshot.

kenven01_0-1714039104955.png

 

Hi @kenven01 ,

 

As you can see from your screenshot the month column of the month table is listed as "Month Level 01" and we need to write the original column name in square brackets []. Modify your calculated column as shown below.

 

Please note that you will need to select the month table and add this calculated column to the month table.

 

 

New month = 
var _a= RIGHT([Month Level 01],4) 
var _b=SWITCH(TRUE(),
CONTAINSSTRING([Month Level 01],"JAN"),"01",
CONTAINSSTRING([Month Level 01],"FEB"),"02",
CONTAINSSTRING([Month Level 01],"MAR"),"03",
CONTAINSSTRING([Month Level 01],"APR"),"04",
CONTAINSSTRING([Month Level 01],"MAY"),"05",
CONTAINSSTRING([Month Level 01],"JUN"),"06",
CONTAINSSTRING([Month Level 01],"JUL"),"07",
CONTAINSSTRING([Month Level 01],"AUG"),"08",
CONTAINSSTRING([Month Level 01],"SEP"),"09",
CONTAINSSTRING([Month Level 01],"OCT"),"10",
CONTAINSSTRING([Month Level 01],"NOV"),"11",
CONTAINSSTRING([Month Level 01],"DEC"),"12")
RETURN INT(_a & _b)

 

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

Hi Neeko,

 

     The screenshot for the previoulsy memtioned error message below.

kenven01_1-1714102759586.png

 

Hi @kenven01 ,

 

(1)Select Month table.

vtangjiemsft_0-1714112000744.png

(2)Create a column.

vtangjiemsft_1-1714112041779.png

 

New month column = 
var _a= RIGHT([Month Level 01],4) 
var _b=SWITCH(TRUE(),
CONTAINSSTRING([Month Level 01],"JAN"),"01",
CONTAINSSTRING([Month Level 01],"FEB"),"02",
CONTAINSSTRING([Month Level 01],"MAR"),"03",
CONTAINSSTRING([Month Level 01],"APR"),"04",
CONTAINSSTRING([Month Level 01],"MAY"),"05",
CONTAINSSTRING([Month Level 01],"JUN"),"06",
CONTAINSSTRING([Month Level 01],"JUL"),"07",
CONTAINSSTRING([Month Level 01],"AUG"),"08",
CONTAINSSTRING([Month Level 01],"SEP"),"09",
CONTAINSSTRING([Month Level 01],"OCT"),"10",
CONTAINSSTRING([Month Level 01],"NOV"),"11",
CONTAINSSTRING([Month Level 01],"DEC"),"12")
RETURN INT(_a & _b)

 

If you want to create a measure, use the following formula.

vtangjiemsft_3-1714112753629.png

 

 

New month measure = 
var _a= RIGHT(MAX('Month'[Month Level 01]),4) 
var _b=SWITCH(TRUE(),
CONTAINSSTRING(MAX('Month'[Month Level 01]),"JAN"),"01",
CONTAINSSTRING(MAX('Month'[Month Level 01]),"FEB"),"02",
CONTAINSSTRING(MAX('Month'[Month Level 01]),"MAR"),"03",
CONTAINSSTRING(MAX('Month'[Month Level 01]),"APR"),"04",
CONTAINSSTRING(MAX('Month'[Month Level 01]),"MAY"),"05",
CONTAINSSTRING(MAX('Month'[Month Level 01]),"JUN"),"06",
CONTAINSSTRING(MAX('Month'[Month Level 01]),"JUL"),"07",
CONTAINSSTRING(MAX('Month'[Month Level 01]),"AUG"),"08",
CONTAINSSTRING(MAX('Month'[Month Level 01]),"SEP"),"09",
CONTAINSSTRING(MAX('Month'[Month Level 01]),"OCT"),"10",
CONTAINSSTRING(MAX('Month'[Month Level 01]),"NOV"),"11",
CONTAINSSTRING(MAX('Month'[Month Level 01]),"DEC"),"12")
RETURN INT(_a & _b)

 

vtangjiemsft_2-1714112290790.png

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

Hi Neeko,

    As I menetioned earlier, new column function is greyed out, so no chance for my case to new a column. That's a tough issue for data source frm SAP query.

   See the screenshot below.

 

kenven01_0-1714115920407.png

 

Hi @kenven01 ,

 

Please try to create a measure.

New month measure = 
var _a= RIGHT(MAX('Month'[Month Level 01]),4) 
var _b=SWITCH(TRUE(),
CONTAINSSTRING(MAX('Month'[Month Level 01]),"JAN"),"01",
CONTAINSSTRING(MAX('Month'[Month Level 01]),"FEB"),"02",
CONTAINSSTRING(MAX('Month'[Month Level 01]),"MAR"),"03",
CONTAINSSTRING(MAX('Month'[Month Level 01]),"APR"),"04",
CONTAINSSTRING(MAX('Month'[Month Level 01]),"MAY"),"05",
CONTAINSSTRING(MAX('Month'[Month Level 01]),"JUN"),"06",
CONTAINSSTRING(MAX('Month'[Month Level 01]),"JUL"),"07",
CONTAINSSTRING(MAX('Month'[Month Level 01]),"AUG"),"08",
CONTAINSSTRING(MAX('Month'[Month Level 01]),"SEP"),"09",
CONTAINSSTRING(MAX('Month'[Month Level 01]),"OCT"),"10",
CONTAINSSTRING(MAX('Month'[Month Level 01]),"NOV"),"11",
CONTAINSSTRING(MAX('Month'[Month Level 01]),"DEC"),"12")
RETURN INT(_a & _b)

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

Hi Neeko,

    Good day.   

    It seems to have data load problem this time.

    Please see the screenshot below.

 

kenven01_1-1714358318057.png

 

 

kenven01_0-1714358282665.png

 

Hi @kenven01 ,

 

Please try to add the month columns displayed as numbers in the data source or connect to the data source in import mode instead.

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

Hi Neeko,

    Nornally we will design PBI report based on queries built on cube(s) from SAP BW.

    Cube data is often seen as the raw data of report, we design query to meet the needs of            report something like  ffiltering, row/column format, caculation formula.

    So, we won't create visualization reports based on cube data directly.

 

    Other than date(month) issue like the case, other characteristics like customer,material with        key id and text value , key id can not displayed properly.

 

    Even though I tried loading data with method of 'Import' mode,

    error is still there.

    See the screenshot below.

 

kenven01_0-1714362328200.png

 

 

    

Hi @kenven01 ,

 

If you are a Power BI Pro licensee, you can create a support ticket for free and a dedicated Microsoft engineer will come to solve the problem for you.
It would be great if you continue to share in this issue to help others with similar problems after you know the root cause or solution.

 

The link of Power BI Support: Support | Microsoft Power BI

For how to create a support ticket, please refer to How to create a support ticket in Power BI - Microsoft Power BI Community

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

Hi Neeko,

 

     I've got it.

     Thank your for your great help.

 

     Kenven01

Hi Neeko, It still doesn't work with error 'The value for 'Month Level 01' cannot be determined. Either the column doesn't exist, or there is no current row for this column'. Regards, Kenven

Hi Neeko, It still doesn't work with error 'The value for 'Month Level 01' cannot be determined. Either the column doesn't exist, or there is no current row for this column'. Regards, Kenven

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.