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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Syndicate_Admin
Administrator
Administrator

Formula emulation

Nice day

I come to your aid with the following situation.

I have a text file with the following structure
In column A (ID) an identification number is related, in column B (Support) the name of the support that each ID has is related, in column C (TYPE) a number assigned according to the type of support is related, in column D (Account) an account number assigned to each ID is related.

FrankGonzalez_0-1679075097166.png

My goal is to get columns E (Quantity) and F (Result).
In column E (Quantity) consecutive number is placed according to the number of media types for each ID and for each type of support. I get this amount in Excel with the function "=IF(A2=A1;IF(C2=C1; E1+1;1);1)" and column F (Result) relates the reslutado I want, which I obtain by concatenating columns D, C and E.

FrankGonzalez_1-1679075129891.png


I tried to perform this procedure in the Power Query editor but I couldn't find a way to get the same result but I couldn't find a way.


I appreciate any help you can offer me.

2 REPLIES 2
jdurmus
New Member

To achieve the same result in Power Query Editor, you can follow these steps:

  1. Load the text file into Power Query Editor by going to "Data" tab and selecting "From Text/CSV".

  2. In the "Navigator" pane, select the file and click on "Edit".

  3. In the Power Query Editor, go to "Add Column" tab and select "Conditional Column".

  4. In the "Conditional Column" dialog box, create a new column named "Quantity" and enter the following formula:

= if [ID] = #"Previous Row"[ID] then if [Support] = #"Previous Row"[Support] then #"Previous Row"[Quantity] + 1 else 1

else 1

 

5. This formula checks if the ID and Support in the current row are the same as the previous row. If they are, it increments the Quantity by 1. Otherwise, it resets the Quantity to

6. Click "OK" to create the new column "Quantity".

7. Go to "Add Column" tab again and select "Custom Column".

8. In the "Custom Column" dialog box, create a new column named "Result" and enter the following formula:

= [Account] & "-" & Text.From([TYPE]) & "-" & Text.From([Quantity])

9. This formula concatenates the Account, TYPE, and Quantity columns into a single string

10. Click "OK" to create the new column "Result".

11. Finally, go to "Home" tab and select "Close & Load" to load the data into Excel.

The resulting table should have the same structure and values as the one you created in Excel.

Hello good afternoon

Unfortunately I did not achieve the result with the instructions you gave me even though they were very clear.

The point I am interested in understanding and knowing how to do is 4.

In the Formula Emulation file.xlsx, with the Excel sheets containing the base with the function I currently use, the Source sheet with the data from the txt file, and the Output sheet which is basically a query generated from the Source sheet.

With the above I hope you can help me by performing step 4 to be able to interpret the formula and understand how it works.

Thank you.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Feb2025 NL Carousel

Fabric Community Update - February 2025

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