Forum Discussion

IMDM's avatar
IMDM
Regular Visitor
1 year ago
Solved

How to create an if statement with multiple conditions

Dear forum, 

 

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

 

 

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. 

 

 

  • 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:

     

    Sample Data:

     

     

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

     

     

10 Replies

  • V-yubandi-msft's avatar
    V-yubandi-msft
    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:

     

     

    Regards,

    Yugandhar.

    • IMDM's avatar
      IMDM
      Regular Visitor

      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

      • V-yubandi-msft's avatar
        V-yubandi-msft
        Community Support

        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:

         

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

         

        Regards,

        Yugandhar.

         

         

  • V-yubandi-msft's avatar
    V-yubandi-msft
    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's avatar
    V-yubandi-msft
    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.