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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
ruinaldo
Helper II
Helper II

Segregate by month Positive and Negative Client Balance

 

I have a list of clients movemented by month. Every month i need to segregate the accumulated values (positive versus negative clients balance) by columns. If the balance movements by client is positive so i write in "Positive Column", otherwise, if the balance movements is negative i write in "Negative Column".

Can you help me please? 

 Question BI.PNG

 

6 REPLIES 6
v-yulgu-msft
Employee
Employee

Hi @ruinaldo,

 

From above image, the left table is source table, and the right one is your desired result, right?

 

Please create a calculated table like this:

Positive & Negative =
ADDCOLUMNS (
    CROSSJOIN (
        VALUES ( 'Client Balance'[Month] ),
        VALUES ( 'Client Balance'[Number Client] )
    ),
    "Movement", LOOKUPVALUE (
        'Client Balance'[Movenments of month],
        'Client Balance'[Month], [Month],
        'Client Balance'[Number Client], [Number Client]
    )
)

And add below calculated columns:

accumulated values =
CALCULATE (
    SUM ( 'Positive & Negative'[Movement] ),
    FILTER (
        ALLEXCEPT ( 'Positive & Negative', 'Positive & Negative'[Number Client] ),
        'Positive & Negative'[Month] <= EARLIER ( 'Positive & Negative'[Month] )
    )
)
    + 0

Positive =
IF (
    'Positive & Negative'[accumulated values] >= 0,
    'Positive & Negative'[accumulated values],
    0
)

Negative =
IF (
    'Positive & Negative'[accumulated values] <= 0,
    'Positive & Negative'[accumulated values],
    0
)

1.PNG

 

To get your desired output, refer to below formula:

Result Table =
SELECTCOLUMNS (
    'Positive & Negative',
    "Month", "Month" & " "
        & 'Positive & Negative'[Month],
    "Number Client", 'Positive & Negative'[Number Client],
    "Positive", 'Positive & Negative'[Positive],
    "Negative", 'Positive & Negative'[Negative]
)

2.PNG

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you very much for your reply Yuliana.

But I have the following error message:

 

Error.PNG

Capture.PNGCapture3.PNGCapture2.PNG

 

I have a problem.......in left table i insert a new row "211000500" "Month1" "300".

In this case i have a number of client that repeats in the same month.

First when i insert a new table give me a error"a table of multiple values was supplied where a single was expected"

Second if i insert a column with accumulated formula (without insert a new table) the result of client 211000500 repeats in the Month1. So when i insert a matrix table the result was duplicated. How can i resolve this? 

Hi @ruinaldo,

 

In that case, before creating the calculated table 'Positive & Negative', please create a summarized table like below:

summarize balance table =
SUMMARIZE (
    'Client Balance',
    'Client Balance'[Number Client],
    'Client Balance'[Month],
    "Movements", SUM ( 'Client Balance'[Movements of Month] )
)

Then, the rest steps are the same based on above summarized table.

 

Regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Capture.PNG

 

Hi,

I have a table of clients movements by month. I don´t need the sum of positive or negative values

I need by month the accumulated values by client. And each month i have client balance positive others negative that i want separate in diferent columns.

Month 1 = positive (650) = acumulated balance of clients 211000500 (500) and 211000700 (150)

Month 2  = positive (350) = acumulated balance of clients 211000500 (200) and 211000700 (150). 

                    negative = acumulated balance of client 211000600 (-100)

 

Thanks for your help.

Hi @ruinaldo,

 

Please try the solution in my original post in Power BI desktop (rather than in Power Pivot) to see whether it works for your data table. Please note that the first and the third formula in my post is used to created a calculated table, not a calculated column. As I know, the DAX supported by Power BI also applies to Power Pivot. If above DAX can return expected result in desktop in your scenario, for how to new a calculated table and how to run DAX correctly in Power Pivot, please post questions in Power Pivot forum to get more helpful answer.

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.