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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
villa1980
Frequent Visitor

Calculate Total Invoice That Contains A Code

Hi all,

 

 I have been asked to show the total invoice value based on that invoice containing a particluar code.

 I can bring back the invoice that contains the code however I cannot bring the total value.

Hope this makes sense

 

 This brings back the value of the code.

 

CALCULATE (
 sum( 'PBI VW_SDW_FAC_SALE_TRANS'[LINE_SELLING_VALUE]),
 FILTER('PBI VW_PRODUCTS_NEW',
 'PBI VW_PRODUCTS_NEW'[CLEARCLASS_LEVEL_3_CODE] = "LS" ))
 
Many Thannks
3 REPLIES 3
v-yifanw-msft
Community Support
Community Support

Hi @villa1980 ,

Thanks @bhanu_gautam  for the prompt reply. I have created an example for you to solve the problem. You can follow the steps below:
1. Create a new CodeTable and establish a relationship with PBI VW_SDW_FAC_SALE_TRANS.

 

CodeTable = DISTINCT('PBI VW_SDW_FAC_SALE_TRANS'[CODE])

 

vyifanwmsft_0-1709800294765.png

2.Create a new measure.

 

TotalInvoiceValueWithCode = 
CALCULATE (
    SUM ( 'PBI VW_SDW_FAC_SALE_TRANS'[LINE_SELLING_VALUE] ),
    FILTER ( 'CodeTable', 'CodeTable'[CODE] = SELECTEDVALUE ( CodeTable[CODE] ) )
)

 

Final output:

vyifanwmsft_1-1709800423422.png

vyifanwmsft_2-1709800442268.png

How to Get Your Question Answered Quickly - Microsoft Fabric Community

If it does not help, please provide more details with your desired out put and pbix file without privacy information.

 

Best Regards,

Ada Wang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

bhanu_gautam
Super User
Super User

@villa1980 , Try using below mentioned method

 

TotalInvoiceValueWithCode =
CALCULATE (
SUM ( 'PBI VW_SDW_FAC_SALE_TRANS'[LINE_SELLING_VALUE] ),
FILTER (
'PBI VW_SDW_FAC_SALE_TRANS',
RELATED ( 'PBI VW_PRODUCTS_NEW'[CLEARCLASS_LEVEL_3_CODE] ) = "LS"
)
)

 

Please accept as solution and give kudos if it helps





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thank-you for the reply, however the related part of this does not bring back the table, I think the table within the related part has a many to many relationship.
Could I do anything with a slicer that brings back those invoice numbers that contain "LS"??

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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