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.
Hello everyone!
I´m trying to develop a personalized step to change the type of some columns in my table on Power Query that have the following structure (Table below).
However, this code will be an tool that will be apply to another data that can create more columns at the right of the table. So, in a future work, the number of columns can increase.
I would like to change the type from the "Column 3" until the end of the table. How can I code some step that can do that even that the numbers of columns increase?
The column 1 and column 2 must not change their type values.
Column 1 | Column 2 | Column 3 | Column 4 | Column 5 | Column 6 | Column 7 |
Name 1 | Name 1 | 6.80 | 3.69 | 6.65 | 2.54 | 1.98 |
Name 2 | Name 2 | 0.69 | 1.22 | 0.80 | 0.72 | 0.11 |
Name 3 | Name 3 | 6.44 | 9.52 | 1.76 | 7.79 | 1.17 |
Name 4 | Name 4 | 2.56 | 3.03 | 0.48 | 3.73 | 0.58 |
Thanks for any help.
Solved! Go to Solution.
The function is also very simple, as it takes just one parameter (a table) as it's input. So you would adjust your query to this:
let Source = Table.Combine({#"fUsage-Peak (REF)", #"fUsage_Off-Peak (REF)", #"fCIP (REF)", #"fTotal Cost (REF)", #"fExcedente Energia Reativa P (REF)", #"fExcedente Energia Reativa FP (REF)", #"fDemand Contracted Off-Peak (VERDE) (REF)", #"fDemand Registered Peak (Actual Null) (REF)", #"fDemand Contracted Peak (VERDE) (REF)", #"fDemand Registered Off Peak (Actual Null) (REF)", #"fDemand Registered Peak (Dem Peak) (REF)", #"fDemand Registered Off Peak (Dem Peak) (REF)", #"fDemanda Contracted Peak (AZUL) (REF)", #"fDemanda Contracted Off Peak (AZUL) (REF)", #"fReactive Demand Peak (REF)", #"fReactive Demand Off Peak (REF)"}), ApplyFunction = FunctionName(Source)
in ApplyFunction
Where "FunctionName" is the name of the query that holds the function code that you have copied.
Please see attached file.
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
This function automatically transforms each column to the type of the value it finds in the first row: https://www.thebiccountant.com/2017/08/10/table-transform-column-types-to-first-rows-types/
Please check if it works for you.
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
Sorry, but I couldn´t use the function because I don´t know how to use the reference of the "(Table)=>" above the code.
I tried to modify the code, but it didn´t work out.
Can you tell me more about how to use this function using a simple example?
Thank you!
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
Unfortunally, I still don´t get it how to use the code. Look, my table so far have the following columns. The columns 1 to 6 always will be in that order. However, from column 7 to final the number of columns can change depending of data range I´ll use.
I would like to set the type from column 7 until the end to "Decimal type". I´m trying to use the code that you´ve sent to me, but I´m still having problem with the first part (red circle on image written "Table").
My code it´s simple because this table it´s an append of others. This is the code.
let Source = Table.Combine({#"fUsage-Peak (REF)", #"fUsage_Off-Peak (REF)", #"fCIP (REF)", #"fTotal Cost (REF)", #"fExcedente Energia Reativa P (REF)", #"fExcedente Energia Reativa FP (REF)", #"fDemand Contracted Off-Peak (VERDE) (REF)", #"fDemand Registered Peak (Actual Null) (REF)", #"fDemand Contracted Peak (VERDE) (REF)", #"fDemand Registered Off Peak (Actual Null) (REF)", #"fDemand Registered Peak (Dem Peak) (REF)", #"fDemand Registered Off Peak (Dem Peak) (REF)", #"fDemanda Contracted Peak (AZUL) (REF)", #"fDemanda Contracted Off Peak (AZUL) (REF)", #"fReactive Demand Peak (REF)", #"fReactive Demand Off Peak (REF)"}) in Source
The function is also very simple, as it takes just one parameter (a table) as it's input. So you would adjust your query to this:
let Source = Table.Combine({#"fUsage-Peak (REF)", #"fUsage_Off-Peak (REF)", #"fCIP (REF)", #"fTotal Cost (REF)", #"fExcedente Energia Reativa P (REF)", #"fExcedente Energia Reativa FP (REF)", #"fDemand Contracted Off-Peak (VERDE) (REF)", #"fDemand Registered Peak (Actual Null) (REF)", #"fDemand Contracted Peak (VERDE) (REF)", #"fDemand Registered Off Peak (Actual Null) (REF)", #"fDemand Registered Peak (Dem Peak) (REF)", #"fDemand Registered Off Peak (Dem Peak) (REF)", #"fDemanda Contracted Peak (AZUL) (REF)", #"fDemanda Contracted Off Peak (AZUL) (REF)", #"fReactive Demand Peak (REF)", #"fReactive Demand Off Peak (REF)"}), ApplyFunction = FunctionName(Source)
in ApplyFunction
Where "FunctionName" is the name of the query that holds the function code that you have copied.
Please see attached file.
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
It worked!
Thank you so much for the help!
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
109 | |
99 | |
77 | |
66 | |
54 |
User | Count |
---|---|
144 | |
104 | |
102 | |
87 | |
64 |