cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
Jeromec
Frequent Visitor

How to Plot Active Transactions by Month

I am relatively new to Power BI and I've been searching for ways to solve this particular scenario. 

 

Essentially I have transactions in a fact table that can span X month. For instance a transaction can start in March and complete in May. I have the start date/end date in my fact table and I am trying to plot by month the number of active transactions. As such, say the transaction started in March and completed May 15, it would be included as an active transaction in my plot for March, April and May. It seems simple enough, can't seem to figure out how to implement that in Power BI.

 

Any help is greatly appreciated.

1 ACCEPTED SOLUTION
v-eqin-msft
Community Support
Community Support

Hi @Jeromec ,

 

I have built a data sample for test.

Eyelyn9_0-1654827921606.png

1. Firstly you need a new table with all year-month period between Start Date and End Date

Year Month =
DISTINCT (
    SELECTCOLUMNS (
        CALENDAR ( MIN ( 'Table'[Start Date] ), MAX ( 'Table'[End Date] ) ),
        "YearMonth",
            YEAR ( [Date] ) * 100
                + MONTH ( [Date] ),
        "Year", YEAR ( [Date] ),
        "Month", FORMAT ( [Date], "mmmm" )
    )
)

Eyelyn9_4-1654828205063.png

 

2. Create a count measure:

Count of each month =
CALCULATE (
    COUNTROWS ( 'Table' ),
    FILTER (
        'Table',
        YEAR ( [Start Date] ) * 100
            + MONTH ( [Start Date] )
            <= MAX ( 'Dates Table'[YearMonth] )
            && YEAR ( [End Date] ) * 100
                + MONTH ( [End Date] )
                >= MAX ( 'Dates Table'[YearMonth] )
    )
)

3. Create a Stacked column chart, and in order to get the correct sorting, please drag the YearMonth field to the Tooltips pane, below is the final output:

Eyelyn9_5-1654828426990.png

 

Or if you are still confused about it, please provide me with more details about your table and your problem or share me with your pbix file after removing sensitive data.

Refer to:

How to Get Your Question Answered Quickly - Microsoft Power BI Community

How to provide sample data in the Power BI Forum - Microsoft Power BI Community

 

 

Best Regards,
Eyelyn Qin
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

3 REPLIES 3
Jeromec
Frequent Visitor

Thank You Evelyn - Apologies about the delay, I got sidetracked with another issue as part of this project, now just getting back to the original issue. I will review and let you know once I've implemented it for my particular situation.

Ashish_Mathur
Super User
Super User

Hi,

Share data in a format that can be pasted in an MS Excel file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-eqin-msft
Community Support
Community Support

Hi @Jeromec ,

 

I have built a data sample for test.

Eyelyn9_0-1654827921606.png

1. Firstly you need a new table with all year-month period between Start Date and End Date

Year Month =
DISTINCT (
    SELECTCOLUMNS (
        CALENDAR ( MIN ( 'Table'[Start Date] ), MAX ( 'Table'[End Date] ) ),
        "YearMonth",
            YEAR ( [Date] ) * 100
                + MONTH ( [Date] ),
        "Year", YEAR ( [Date] ),
        "Month", FORMAT ( [Date], "mmmm" )
    )
)

Eyelyn9_4-1654828205063.png

 

2. Create a count measure:

Count of each month =
CALCULATE (
    COUNTROWS ( 'Table' ),
    FILTER (
        'Table',
        YEAR ( [Start Date] ) * 100
            + MONTH ( [Start Date] )
            <= MAX ( 'Dates Table'[YearMonth] )
            && YEAR ( [End Date] ) * 100
                + MONTH ( [End Date] )
                >= MAX ( 'Dates Table'[YearMonth] )
    )
)

3. Create a Stacked column chart, and in order to get the correct sorting, please drag the YearMonth field to the Tooltips pane, below is the final output:

Eyelyn9_5-1654828426990.png

 

Or if you are still confused about it, please provide me with more details about your table and your problem or share me with your pbix file after removing sensitive data.

Refer to:

How to Get Your Question Answered Quickly - Microsoft Power BI Community

How to provide sample data in the Power BI Forum - Microsoft Power BI Community

 

 

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

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors