You don’t need to know any M Code to do this. Just go to the PQ menu, and select Add Column and then Conditional Column. A form will pop up, and you just fill in the blanks, and it will automatically write the M Code for you.
Unfortunately, it’s incorrect as few entries are double-counted. I applied your workings to my file but I literally received the same result which is incorrect.
Excel Formula Total:
In the below file there is a total but also I did few calculations in order to get to 209,132,868.40
Please see Cell Y7 and Y9 sum of them give us the correct results m code.xlsx (1.3 MB)
While I use your technique and mine I get 216,104,183.73 Transformation.pbix (537.6 KB)
Please let me explain what I want to achieve:
As in your file, I want to drill down period and month for each transaction but I need to exclude transactions that are:
where the row line is with * in Alt account
Highlighted in yellow values equal to the green. I would like to keep values highlighted in green as they give an alt account also drill down period and dates.
The issue come in point 2
Some of the values are in one line which would be perfect for us but there some values that have a split and total:
Once again I would like to show only value in green.
Keeping any individual entries that are alone:
The issue comes when you need to differentiate between below transactions:
Okay so I misunderstood your requirement, sorry about that, results now match your xlsx
Turned out to be straight forward with the logic from your excel sheet, just added one Custom Column if [Period] is date and [Acct Code] is text and [Acct Code] <>"" then “Date” else if [Acct Code] ="" then “Astriks” else null
Now the query returned one error, I separated that but you will have to check that
As I mentioned before the total = 209,132,868.40, your formula and results equal to my results in Excel, but this is not where I stuck. Apologies, maybe I did;t explain it very well.
My issue is with data Transformation.
As I written before the file contains transactions.
There are 3 types of transactions(the number of rows for 1 and 2 can be increased or decreased, its a split of the total main row (highlighted in yellow)as I mentioned in my previous post):
In excel file I wrote many other logic separators to find a way in order to transform data to get to the result below:
(done manually as I can’t find a logic way how can I do it)
Then (1) check if there are multiple rows inside the nested table
if there are; (2) fill down values and (3) removed the first row
else (4) return the table as is
Thank you @Melissa slowly I am studying your formula to have good understanding of the M code.
I think it worked I get the correct results for Net Gross or VAT amount.
Please allow me to check on smaller data if it will match to excel ( I believe it does just want check as it was driving me crazy today as I wan;t be able to do it on my own )
I noticed you have added parameter to the file source.
Before you have created the parameter did you first imported source from excel, then added a parameter and then you changed the source meaning replacing it with parameter?
No I created the parameter first and then replaced the hard coded file location in the source step of each of your queries but the order is not that important, although I tend to create my parameters first.