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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
NithinBN
Helper II
Helper II

Inflow and outflow

Hello, 

I am having 2 colums one for  item Purchased date and another for item sold date.

 

I want to see how many items were purchased and how many were sold in Month n Month basis (month wise trend bar.)

I want both line\bar in same chart. 

How i can achieve this.

 

NithinBN_0-1617778483136.png

 

2 ACCEPTED SOLUTIONS
Jihwan_Kim
Super User
Super User

Hi, @NithinBN 

If you have Dim-Date-Table, you can connect it with your main table with two relationship lines.

One is active with purchase date column, and the other is inactive with sold date column.

By using the active relationship, you can create the measure to distinctcount the item numbers purchased.

By using the inactive relationship, you can create

                       calculate ( your measure, userelationship ( datecolumn, sold date column))

to distinctcount the item numbers sold.

 

Please check the below picture and the link down below (sample pbix file)

all measures are in the sample pbix file.

 

Picture4.pngPicture5.png

 

https://www.dropbox.com/s/k2pkh8b5qtn79cl/NithinBN.pbix?dl=0 

 

 

Hi, My name is Jihwan Kim.

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

v-luwang-msft
Community Support
Community Support

Hi @NithinBN ,

You could try the following steps:

base table :

v-luwang-msft_2-1619170902725.png

 

 

1.Create month table:

MonthTable = 
VAR FullCalendar =
    ADDCOLUMNS (
        CALENDAR ( "2019/12/1", "2021/1/31" ),
        "Month Number", MONTH ( [Date] ),
        "Year", YEAR ( [Date] ),
        "Year-Month", LEFT ( FORMAT ( [Date], "yyyyMMdd" ), 6 ),
        "Month Name", FORMAT ( MONTH ( [Date] ), "MMM" ),
        "Year-MonthName",
            YEAR ( [Date] ) & " "
                & FORMAT ( MONTH ( [Date] ), "MMM" )
    )
RETURN
    SUMMARIZE (
        FullCalendar,
        [Month Number],
        [Year],
        [Year-Month],
        [Year-MonthName]
    )

 

v-luwang-msft_0-1619170853217.png

Step2,create the following measure on month table:

pcount = CALCULATE(COUNTROWS('Table'),FILTER(ALL('Table'),MAX(MonthTable[Year])=YEAR('Table'[Purchased Date])&&MAX(MonthTable[Month Number])=MONTH('Table'[Purchased Date])))
scount = CALCULATE(COUNTROWS('Table'),FILTER(ALL('Table'),MAX(MonthTable[Year])=YEAR('Table'[Sold date])&&MAX(MonthTable[Month Number])=MONTH('Table'[Sold date])))

 

Then create visualization,you will get what you want:

 

v-luwang-msft_3-1619171069859.png

 

 

Wish it is helpful for you!

 

Best Regards

Lucien

View solution in original post

3 REPLIES 3
v-luwang-msft
Community Support
Community Support

Hi @NithinBN ,

You could try the following steps:

base table :

v-luwang-msft_2-1619170902725.png

 

 

1.Create month table:

MonthTable = 
VAR FullCalendar =
    ADDCOLUMNS (
        CALENDAR ( "2019/12/1", "2021/1/31" ),
        "Month Number", MONTH ( [Date] ),
        "Year", YEAR ( [Date] ),
        "Year-Month", LEFT ( FORMAT ( [Date], "yyyyMMdd" ), 6 ),
        "Month Name", FORMAT ( MONTH ( [Date] ), "MMM" ),
        "Year-MonthName",
            YEAR ( [Date] ) & " "
                & FORMAT ( MONTH ( [Date] ), "MMM" )
    )
RETURN
    SUMMARIZE (
        FullCalendar,
        [Month Number],
        [Year],
        [Year-Month],
        [Year-MonthName]
    )

 

v-luwang-msft_0-1619170853217.png

Step2,create the following measure on month table:

pcount = CALCULATE(COUNTROWS('Table'),FILTER(ALL('Table'),MAX(MonthTable[Year])=YEAR('Table'[Purchased Date])&&MAX(MonthTable[Month Number])=MONTH('Table'[Purchased Date])))
scount = CALCULATE(COUNTROWS('Table'),FILTER(ALL('Table'),MAX(MonthTable[Year])=YEAR('Table'[Sold date])&&MAX(MonthTable[Month Number])=MONTH('Table'[Sold date])))

 

Then create visualization,you will get what you want:

 

v-luwang-msft_3-1619171069859.png

 

 

Wish it is helpful for you!

 

Best Regards

Lucien

Jihwan_Kim
Super User
Super User

Hi, @NithinBN 

If you have Dim-Date-Table, you can connect it with your main table with two relationship lines.

One is active with purchase date column, and the other is inactive with sold date column.

By using the active relationship, you can create the measure to distinctcount the item numbers purchased.

By using the inactive relationship, you can create

                       calculate ( your measure, userelationship ( datecolumn, sold date column))

to distinctcount the item numbers sold.

 

Please check the below picture and the link down below (sample pbix file)

all measures are in the sample pbix file.

 

Picture4.pngPicture5.png

 

https://www.dropbox.com/s/k2pkh8b5qtn79cl/NithinBN.pbix?dl=0 

 

 

Hi, My name is Jihwan Kim.

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
amitchandak
Super User
Super User

@NithinBN , You need to create a common date table and join both date with that. One join will be inactive. You have to use userelationship in measure to use that join.

 

Refer to my hr blog , to check how to use two dates

https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.