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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

RE: Sum value on other column Under same name in rows

Hi,

 

Good day.

 

I do have problem creating DAX to my report. See details below:

 

here's my generated report or the origin file:

8470B56E-E0CB-44EA-973B-0A8051925315.jpeg

 

and I want the file above turn into this:4585BAC1-D30D-49C5-96B6-DEC7A046F3B6.jpeg

 

Please disregard other column if you find it hard to create DAX. I only need to the Audited Amount and the Doc Code - relationship.

 

thanks in advance

2 ACCEPTED SOLUTIONS

Hi, @Anonymous 

 

Please modify the calculated table as below.

Result table = 
var tab =
FILTER(
        SUMMARIZE(
           'Table',
           'Table'[Doc Code],
           'Table'[Doc Code Sign],
           'Table'[Orig Amount],
           'Table'[Department]
        ),
        'Table'[Doc Code Sign] = "Y"
)
var newtab = 
ADDCOLUMNS(
    tab,
    "Row#",
    RANKX(
        tab,
        [Doc Code],,ASC
    )
)
var result = 
ADDCOLUMNS(
    newtab,
    "Audited Amt",
    IF(
        COUNTROWS(
            FILTER(
                ALL('Table'),
                'Table'[Doc Code]=EARLIER('Table'[Doc Code])
            )
        )=
        COUNTROWS(
            FILTER(
                ALL('Table'),
                'Table'[Doc Code]=EARLIER('Table'[Doc Code])&&
                'Table'[Doc Code Sign] = "Y"
            )
        ),
        CALCULATE(
            SUM('Table'[Audited Amt]),
            FILTER(
                ALL('Table'),
                'Table'[Doc Code]=EARLIER('Table'[Doc Code])
            )
        ),
        CALCULATE(
            SUM('Table'[Audited Amt]),
            FILTER(
                ALL('Table'),
                'Table'[Doc Code]=EARLIER('Table'[Doc Code])&&
                'Table'[Doc Code Sign]<>"Y"
            )
        )
    )
)
return
result 

 

Result:

f1.png

 

Best Regards

Allan

 

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

View solution in original post

Anonymous
Not applicable

6 REPLIES 6
v-alq-msft
Community Support
Community Support

Hi, @Anonymous 

 

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

Table:

a1.png

 

You may create a calculated table as below.

Result table = 
var tab =
FILTER(
        SUMMARIZE(
           'Table',
           'Table'[Doc Code],
           'Table'[Doc Code Sign],
           'Table'[Orig Amount],
           'Table'[Department]
        ),
        'Table'[Doc Code Sign] = "Y"
)
var newtab = 
ADDCOLUMNS(
    tab,
    "Row#",
    RANKX(
        tab,
        [Doc Code],,ASC
    )
)
var result = 
ADDCOLUMNS(
    newtab,
    "Audited Amt",
    IF(
        COUNTROWS(
            FILTER(
                ALL('Table'),
                'Table'[Doc Code]=EARLIER('Table'[Doc Code])
            )
        )<=2,
        CALCULATE(
            SUM('Table'[Audited Amt]),
            FILTER(
                ALL('Table'),
                'Table'[Doc Code]=EARLIER('Table'[Doc Code])
            )
        ),
        CALCULATE(
            SUM('Table'[Audited Amt]),
            FILTER(
                ALL('Table'),
                'Table'[Doc Code]=EARLIER('Table'[Doc Code])&&
                'Table'[Doc Code Sign]<>"Y"
            )
        )
    )
)
return
result

 

Result:

a2.png

 

Best Regards

Allan

 

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

Anonymous
Not applicable

 

@v-alq-msft 

Hi,

 

Good day.

 

Thanks for this. However, what if this is my origin table (see below). I just changed a bit from the data. I used the same formula (DAX) but it didnt give the same result.

 

Capture0001.PNG

 

 

 

The outcome is the same:

 

4585BAC1-D30D-49C5-96B6-DEC7A046F3B6.jpeg

 

 

 

 

TIA 🙂

Hi, @Anonymous 

 

I modified the data as what you have done. It works properly. The pbix file is attached in the end.

e1.png

 

e2.png

 

Best Regards

Allan

 

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

Anonymous
Not applicable

Hi,

 

Apology but the outcome gave different result. See difference below:

 

  • From DAX suggested - Outcome: Row#1 (Column: Audited Amt) = 1000

Capture0003.PNG

 

 

 

 

 

 

  • My Expected Outcome: Row#1 (Column: Audited Amt) = 500

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

     

     

     

     

     

     

To reiterate, this is the base data, in highlighted color:

Capture0001.PNG

 

 

 

 

 

 

 

 

TIA 🙂

Hi, @Anonymous 

 

Please modify the calculated table as below.

Result table = 
var tab =
FILTER(
        SUMMARIZE(
           'Table',
           'Table'[Doc Code],
           'Table'[Doc Code Sign],
           'Table'[Orig Amount],
           'Table'[Department]
        ),
        'Table'[Doc Code Sign] = "Y"
)
var newtab = 
ADDCOLUMNS(
    tab,
    "Row#",
    RANKX(
        tab,
        [Doc Code],,ASC
    )
)
var result = 
ADDCOLUMNS(
    newtab,
    "Audited Amt",
    IF(
        COUNTROWS(
            FILTER(
                ALL('Table'),
                'Table'[Doc Code]=EARLIER('Table'[Doc Code])
            )
        )=
        COUNTROWS(
            FILTER(
                ALL('Table'),
                'Table'[Doc Code]=EARLIER('Table'[Doc Code])&&
                'Table'[Doc Code Sign] = "Y"
            )
        ),
        CALCULATE(
            SUM('Table'[Audited Amt]),
            FILTER(
                ALL('Table'),
                'Table'[Doc Code]=EARLIER('Table'[Doc Code])
            )
        ),
        CALCULATE(
            SUM('Table'[Audited Amt]),
            FILTER(
                ALL('Table'),
                'Table'[Doc Code]=EARLIER('Table'[Doc Code])&&
                'Table'[Doc Code Sign]<>"Y"
            )
        )
    )
)
return
result 

 

Result:

f1.png

 

Best Regards

Allan

 

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

Anonymous
Not applicable

Thanks a lot! @v-alq-msft 

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors
Top Kudoed Authors