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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

columns to rows in direct mode

Hi All,

 

I am using direct query mode. Kindly help me to build dax to get desired output table.

 

Thanks

 

Sample Data

Account NumberLine NumberAddress
10011AAAAAAAA
10012BBBBBB
10013CCCCCC
10014DDDDDD
10015EEEEEE

 

Desired O/p

AccountAddress 1Address 2Address 3Address 4Address 5
1001AAAAAAAABBBBBBCCCCCCDDDDDDEEEEEE
7 REPLIES 7
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @Anonymous ,

By my tests with Direct Query, you may could try unpivot in query editor. Please refer to the M Query.

let
    Source = Sql.Database("xxxxxx", "cherry"),
    dbo_Table_8 = Source{[Schema="dbo",Item="Table_8"]}[Data],
    #"Changed Type" = Table.TransformColumnTypes(dbo_Table_8,{{"Line Number", type text}}),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Account Number", "Line Number"}, "Attribute", "Value"),
    #"Added Custom" = Table.AddColumn(#"Unpivoted Columns", "Custom", each [Attribute]&""&[Line Number]),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Line Number", "Attribute"})
in
    #"Removed Columns"

Here is the output.

Untitled.png

Best Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Plz consider the below screenshot

as per the screenshot u have provided where custom is exp_line_number, address is explantion, account mnumber is transaction_sys_no . 

 

Unable to re-create the same M-code on my file  

 

 

sample.JPG

Anonymous
Not applicable

unable to recreate the same in my application .

 

From where u got line number field 

PattemManohar
Community Champion
Community Champion

@Anonymous  If the source is a database, I suggest to write a SQL Query using UNPIVOT while retrieving the data itself in Direct Query mode. Let me know if you are happy with that approach.





Did I answer your question? Mark my post as a solution!

Proud to be a PBI Community Champion




Anonymous
Not applicable

issue.JPG

Anonymous
Not applicable

i have written a dax query which returns values for the dimension wise .. if there is no values for any particular dimension then its not showning the dimension also . so , i have written if considition on the measure using isblank but i m getting error while using this if condition . could you help how to fix it . 

If dont mind can i have ur mobile number if u r from india . 

 

Dimension:

Account number, trascation number 

Measure :

EXPLANATION1_R=CALCULATE(LASTNONBLANK('TRANSACTION EXPLANATIONS'[EXPLANATION],1),'TRANSACTION EXPLANATIONS'[EXPLANATION_LINE_NUMBER]=1)
EXPLANATION2_R=CALCULATE(LASTNONBLANK('TRANSACTION EXPLANATIONS'[EXPLANATION],1),'TRANSACTION EXPLANATIONS'[EXPLANATION_LINE_NUMBER]=2)
 
the above measures might have null values for those dimensions . I want replace those null values with "N/A".  

 

Thanks,

Anonymous
Not applicable

Thanks for respnse ..

 

we are strictly advice not to write any  sql stmt . so , looking forwards for any dax query help .

 

Thanks  

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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