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
Anonymous
Not applicable

RE: Unique sum

Hi. Team. I need your help on this. I have to make a report before the end of the month. 

 

From this table:

 

Capture0001.PNG

 

 

 

To this outcome:

 

10437601-AAAA-4B70-B0D6-B7486F2FB822.jpeg

 

 

 

 

 

Hope this can help. TIA 

 

 

1 REPLY 1
DataInsights
Super User
Super User

@Anonymous,

 

Here's a solution based on my understanding of the requirements:

 

1. Orig Amount in the table visual is the sum of Orig Amount where Doc Code Sign = Y.

2. Audited Amt in the table visual is calculated as follows:

a. Count the number of rows for each Doc Code.

b. If count = 1, then sum Audited Amt.

c. If count > 1, then sum Audited Amt where Doc Code Sign <> Y.

 

Solution:

 

1. Create three measures. The second measure is used for calculation only; it is not displayed in the table visual.

Total Orig Amount = CALCULATE ( SUM ( Docs[Orig Amount] ), Docs[Doc Code Sign] = "Y" )

Audited Amount Calc = 
VAR vAuditAmt =
    SUM ( Docs[Audited Amt] )
VAR vCurDocCode =
    MAX ( Docs[Doc Code] )
VAR vCurDocCodeRows =
    FILTER ( ALL ( Docs ), Docs[Doc Code] = vCurDocCode )
VAR vCountDocCode =
    COUNTROWS ( vCurDocCodeRows )
VAR vRowsToSum =
    FILTER ( vCurDocCodeRows, Docs[Doc Code Sign] <> "Y" )
VAR vResult =
    IF ( vCountDocCode = 1, vAuditAmt, SUMX ( vRowsToSum, Docs[Audited Amt] ) )
RETURN
    vResult

Total Audited Amount = 
--this measure is necessary in order to properly calculate totals
VAR vDocCodeTable =
    ADDCOLUMNS (
        SUMMARIZE ( Docs, Docs[Doc Code] ),
        "AuditedAmountCalc", [Audited Amount Calc]
    )
VAR vResult =
    SUMX ( vDocCodeTable, [AuditedAmountCalc] )
RETURN
    vResult

 

2. Create a table visual and filter Doc Code Sign = Y.

 

DataInsights_0-1599420014227.png

 

DataInsights_1-1599420136670.png

 





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

Proud to be a Super User!




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.

Top Solution Authors