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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
shahidalaila23
Frequent Visitor

how to get total amount excluding specific data

I need to get net amt for loc_group with loc_group 1034 total amt is excluding the amt that was send to other loc_group. 

 

the situation as below: 

below table represent loc_group and supp_code total amt. Only 1034 will buy item c from supp_code S-03 and will send 1 to other loc_group.

 

This is purchase table

shahidalaila23_0-1672903183274.png

 

and this is transfer table

shahidalaila23_1-1672903447736.png

I have both table in power BI

below is the expected outcome: 

shahidalaila23_2-1672903506999.png

so far I cannot seperate the amt from 1034 in powerBI 

 

thank you;

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your data model looks like, but please check the below picture and the attached pbix file.

 

Jihwan_Kim_0-1672908821263.png

 

Jihwan_Kim_1-1672909328103.png

 

Amount total expected result: =
VAR _expected =
    SUM ( Purchase[amt] )
        - CALCULATE (
            SUM ( Purchase[amt] ),
            FILTER ( ALL ( Purchase ), Purchase[supp_code] = "1034" )
        )
RETURN
    IF (
        HASONEVALUE ( loc_group[loc_group] ),
        SWITCH (
            SELECTEDVALUE ( loc_group[loc_group] ),
            "1034", _expected,
            SUM ( Purchase[amt] )
        ),
        _expected
    )

 


 

    Microsoft MVP
 

 

   


      If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


   


     
        LinkedInVisit my LinkedIn page
     

   


   


     
        Outlook BookingSchedule a short Teams meeting to discuss your question

     

   


 


View solution in original post

1 REPLY 1
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your data model looks like, but please check the below picture and the attached pbix file.

 

Jihwan_Kim_0-1672908821263.png

 

Jihwan_Kim_1-1672909328103.png

 

Amount total expected result: =
VAR _expected =
    SUM ( Purchase[amt] )
        - CALCULATE (
            SUM ( Purchase[amt] ),
            FILTER ( ALL ( Purchase ), Purchase[supp_code] = "1034" )
        )
RETURN
    IF (
        HASONEVALUE ( loc_group[loc_group] ),
        SWITCH (
            SELECTEDVALUE ( loc_group[loc_group] ),
            "1034", _expected,
            SUM ( Purchase[amt] )
        ),
        _expected
    )

 


 

    Microsoft MVP
 

 

   


      If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


   


     
        LinkedInVisit my LinkedIn page
     

   


   


     
        Outlook BookingSchedule a short Teams meeting to discuss your question

     

   


 


Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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