cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted

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

Accepted Solutions
Highlighted
Community Support
Community Support

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

Hi, @gericho_diaz_17 

 

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

Highlighted

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

6 REPLIES 6
Highlighted
Community Support
Community Support

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

Hi, @gericho_diaz_17 

 

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.

Highlighted

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

 

@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 🙂

Highlighted
Community Support
Community Support

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

Hi, @gericho_diaz_17 

 

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.

Highlighted

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

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 🙂

Highlighted
Community Support
Community Support

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

Hi, @gericho_diaz_17 

 

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

Highlighted

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

Helpful resources

Announcements

August Community Highlights

Check out a full recap of the month!

August 2020 CYST Challenge

Check out the winners of the recent 'Can You Solve These?' community challenge!

Experience what’s next for Power BI

Join us for an in-depth look at the new Power BI features and capabilities at the free Microsoft Business Applications Launch Event.

Top Solution Authors
Top Kudoed Authors