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
Laocsulak
Helper I
Helper I

Create bar graph of unpaid transactions having transaction created and payment date

Hello,

 

I need to meet the following requirement and I am not sure what is the best way to do it.

 

At work, we have a table with transactions that may or may not have been paid. The date the transaction was made is indicated in the field created_date and the date the payment was made is indicated in the field completed_date (and it remains null if the payment was not made).

I am being asked for a report and also a filter that allows indicating for the close of each month the amount of unpaid transactions.


I made a simple dummy example with only 3 transactions to better explain the requirement:

Drive: https://drive.google.com/drive/folders/1IdWHQoiPgHx13HwRPV_8Nc4HvIRAGM_5?usp=sharing

Laocsulak_0-1685220852302.png

 

If I analyze the closing of the periods 202302, 202303, and 202304, I should get the following:

202302: $10 because there was a transaction created in period 202302.
202303: $110 because the transaction from 202302 of $10 is still unpaid and a $100 transaction was also created in period 202303.
202304: $100 because the $10 transaction was paid.


So I should get this:

Laocsulak_1-1685220916120.png

 

Does anyone know if there's a DAX script or any transformations recommended to achieve this?

Thanks in advance!

 

 

 

1 REPLY 1
barritown
Super User
Super User

Hello @Laocsulak,

There are many ways to tackle your problem. The one I propose below may not be optimal but it works.

The idea is to create an additional table and a measure.

The additional table is to be created with this [DAX] code:

NewTable = 
UNION (
    SUMMARIZE ( data, [created_month], "amount", SUM (data[amount] ) ),
    SUMMARIZE ( FILTER ( data, NOT ISBLANK ( data[completed_month] ) ), 
                [completed_month], 
                "amount", -SUM ( data[amount] ) ))

It will look like that:

barritown_0-1685348536430.png

The measure should look like that:

 

Measure = 
VAR CurrentMonth = MAX ( NewTable[created_month] )
RETURN CALCULATE ( SUM ( NewTable[amount] ), ALL ( NewTable ),NewTable[created_month] <= CurrentMonth )

 

Once done, you create a bar chart. 

barritown_1-1685348679669.png

Then you can rename axis and enjoy the result. 

Best Regards,

Alexander

My YouTube vlog in English

My YouTube vlog in Russian

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