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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
IMDM
Regular Visitor

How to create an if statement with multiple conditions

Dear forum, 

 

I need some help with putting together the right if statement in Powerquery. 

 

IMDM_0-1747639897906.png

 

I need to put together an if statement that also checks on the period. Kind of like the sums if in excel. So for example: 

 

When account is 63110 -> I want the total amount after corrections to show the following: 

Total corrections multiplied by -1 + the amount but only for the specific period of 1-1-2025, since other months are also in the file. 

The output should combine the amount of € 142.350,- and € 1.468.310,03 and multiply these by -1 and then adds the amount of € 1.086.681,92.  I also need to put together 2 other calculations but if someone can help me with this one, I should be able to figure out the other one myself. 

 

Really appreciate the help. 

 

 

1 ACCEPTED SOLUTION

Hi @IMDM ,

I've set up the Power Query logic to automatically adjust the Amount after correction based on each period and GL, so there's no need for manual filtering. The query first groups data by GL + Date, calculates the total corrections for that specific period, flips the corrections by multiplying them by -1, and then applies the adjustment to each row. This works similarly to the SUMIFS function in Excel, but now it's fully dynamic within Power Query, ensuring the corrections are applied correctly across multiple periods.

 

FYI:

Vyubandimsft_3-1748943904072.pngVyubandimsft_4-1748943915989.png

 

Sample Data:

Vyubandimsft_5-1748944258470.png

 

 

I hope this helps. Feel free to reach out if you need any additional information.

 

 

View solution in original post

10 REPLIES 10
V-yubandi-msft
Community Support
Community Support

Hi @IMDM ,

We wanted to check in and see if your issue has been resolved. If so, we’d appreciate it if you could share your solution or workaround and mark the appropriate response as the accepted answer. This helps other community members facing similar challenges find solutions more quickly.

 

If we don’t hear back, we’ll go ahead and close this thread. Should you need further assistance in the future, we encourage you to reach out via the Microsoft Fabric Community Forum and create a new thread. We’ll be happy to help.

 

Yugandhar – Community Support Team.

V-yubandi-msft
Community Support
Community Support

Hi @IMDM ,

May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.

Thank you.

V-yubandi-msft
Community Support
Community Support

Hi @IMDM ,

Thank you for reaching out to the Fabric community. I have tested your scenario and attached a snapshot of the results based on your requirements. Please review the attachment and confirm whether it meets your expectations or if any adjustments are needed?
FYI:

Vyubandimsft_1-1747673674879.png

 

 

Regards,

Yugandhar.

Dear Yugandhar, 

 

The snapshot only shows the total adjusted correction and it does show the correct amount. Could you please share with me how you got to that result? And has it been done in Powerquery? Since the snapshot is showing a powerbi snapshot? I'm asking this, because I'm currently using Powerquery within Excel, not within Powerbi. I look forward to hearing from you. Thank you for the help!

 

With kind regards, 

 

IMDM

Hi @IMDM ,

Thank you for the clarification, sorry for the earlier misunderstanding.  Yes, I had originally done the calculation in Power BI, but I’ve now recreated it in Power Query within Excel following your setup.

I filtered the data for

  1. Account = 63110

  2. Period = 1-1-2025

Then, I added a custom column using this logic:

Adjusted Total = [Total corrections] * -1 + [Amount]

FYI:

Vyubandimsft_0-1747744247029.png

 

This results in the expected value of -523,978.11, as you described. 

 

Regards,

Yugandhar.

 

 

Dear Yugandhar, 

 

Thank you for your reply and my apologies for the late response but this solution won't work. I don't just want to see that data for the month of January, but in case the month is for February I want the custom column to only show the amount for February. So the filter option won't work, I need that filter to be included in the M formula. I have now created it in excel using the sumsif formula, which looks like this: =(IF([@[Nr.]]=63110;(-SUMSIF(H:H;C:C;[@Date];A:A;[@Company])+[@Amount]);[@Amount]))

 

My apologies if I didn't clarify this enough. I hope you can help me solve this problem. 

 

With kind regards, 

 

IMDM

Hi @IMDM ,

Could you share sample data along with the expected output? Having these details will help us address your issue more effectively. Please provide the necessary information here so we can assist you better.

 

Thank You.

Dear Yubandi, 

 

I've put together a sample sheet, which shows what the expected output should be. I think the solution might be to use groups but I haven't worked it out fully yet. 

 

I can't seem to attach the excel sheet, so I've copied it in as a table: 

GLDate Amount  Correction  valuation  Correction revenu  Correctie completion  Total corrections  Amount after correction 
611101-1-2025       346.509,15                                            -346.509,15                                                  -                                                      -                -346.509,15                                  346.509,15
611201-1-2025         45.686,11                                              -45.686,11                                                  -                                                      -                  -45.686,11                                    45.686,11
611301-1-2025       145.402,67                                            -145.402,67                                                  -                                                      -                -145.402,67                                  145.402,67
611401-1-2025       233.314,24                                            -233.314,24                                                  -                                                      -                -233.314,24                                  233.314,24
611501-1-2025       360.114,15                                            -360.114,15                                                  -                                                      -                -360.114,15                                  360.114,15
611601-1-2025     -433.099,04                                             433.099,04                                                  -                                                      -                  433.099,04                                -433.099,04
611701-1-2025       220.502,31                                            -220.502,31                                                  -                                                      -                -220.502,31                                  220.502,31
621101-1-2025   1.200.973,74                                                               -                                 -524.734,42                                                    -                -524.734,42                              1.200.973,74
631101-1-2025  -2.119.403,33                                                               -                                                    -                                                      -                                   -                                  -676.239,32
801101-1-2025                         -                                                                 -                                                    -                                                      -                                   -                                  -918.429,59
850701-1-2025                         -                                                                 -                                                    -                                                      -                                   -                                  -524.734,42
611101-2-2025       344.098,80                                            -344.098,80                                                  -                                                      -                -344.098,80                                  344.098,80
611201-2-2025         56.244,96                                              -56.244,96                                                  -                                                      -                  -56.244,96                                    56.244,96
611301-2-2025       140.001,66                                            -140.001,66                                                  -                                                      -                -140.001,66                                  140.001,66
611401-2-2025       199.865,83                                            -199.865,83                                                  -                                                      -                -199.865,83                                  199.865,83
611501-2-2025       378.891,39                                            -378.891,39                                                  -                                                      -                -378.891,39                                  378.891,39
611601-2-2025     -100.016,19                                             100.016,19                                                  -                                                      -                  100.016,19                                -100.016,19
611701-2-2025       219.677,39                                            -219.677,39                                                  -                                                      -                -219.677,39                                  219.677,39
621101-2-2025     -549.101,18                                                               -                                 -171.202,68                                                    -                -171.202,68                                -549.101,18
631101-2-2025     -689.662,66                                                               -                                                    -                                                      -                                   -                                2.305.053,86
801101-2-2025   1.584.750,00                                                               -                                                    -                               -1.584.750,00          -1.584.750,00                            -1.238.763,84
850701-2-2025                         -                                                                 -                                                    -                                                      -                                   -                                  -171.202,68

 

thank you!

 

Hi @IMDM ,

I've set up the Power Query logic to automatically adjust the Amount after correction based on each period and GL, so there's no need for manual filtering. The query first groups data by GL + Date, calculates the total corrections for that specific period, flips the corrections by multiplying them by -1, and then applies the adjustment to each row. This works similarly to the SUMIFS function in Excel, but now it's fully dynamic within Power Query, ensuring the corrections are applied correctly across multiple periods.

 

FYI:

Vyubandimsft_3-1748943904072.pngVyubandimsft_4-1748943915989.png

 

Sample Data:

Vyubandimsft_5-1748944258470.png

 

 

I hope this helps. Feel free to reach out if you need any additional information.

 

 

Thank you very much Yubandi for your continious effort to solve this problem!

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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