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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Vaibhav3008
Frequent Visitor

Count of rows based on start date and end date column

Hi All,

I have a table like below

Vaibhav3008_0-1696507812824.png

I need to count the number of app ids which fall in each month (e.g. how many app ids are there in oct 2023, how many in nov 2023 and so on). 

After that I need to display it on a stacked bar chart with functional group as legend. months as x axis and count of app ids as y axis.

Any help would be appreciated. 

Thanks

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

Hi @Vaibhav3008,

 

Based on your description, I make the new DAX expression, you may check the result below:

 

App Count = 
var _selyear=SELECTEDVALUE('DateTable'[Date].[Year])
var _selmonth=SELECTEDVALUE('DateTable'[Date].[MonthNo])
var _date1= EOMONTH(date(_selyear,_selmonth,1),0)
var _date2= date(_selyear,_selmonth,1)
return
COUNTROWS(
    FILTER(
        'Table',
        'Table'[Start Date] <=_date1 &&
        'Table'[End Date] >=  _date2
    )

)

 

 vtianyichmsft_0-1696578047349.png

 

 

Hope it helps.

 

Best regards,


Community Support Team_ Scott Chang

 

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

8 REPLIES 8
v-tianyich-msft
Community Support
Community Support

Hi @Vaibhav3008,

 

Based on your description, I make the new DAX expression, you may check the result below:

 

App Count = 
var _selyear=SELECTEDVALUE('DateTable'[Date].[Year])
var _selmonth=SELECTEDVALUE('DateTable'[Date].[MonthNo])
var _date1= EOMONTH(date(_selyear,_selmonth,1),0)
var _date2= date(_selyear,_selmonth,1)
return
COUNTROWS(
    FILTER(
        'Table',
        'Table'[Start Date] <=_date1 &&
        'Table'[End Date] >=  _date2
    )

)

 

 vtianyichmsft_0-1696578047349.png

 

 

Hope it helps.

 

Best regards,


Community Support Team_ Scott Chang

 

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

BeaBF
Memorable Member
Memorable Member

@Vaibhav3008 Hi!

Can you paste the data?

 

BBF

Thanks for the reply. Here it is:

Functional GroupApp IdStart DateEnd Date
FG01App0119-06-202327-06-2023
FG02App0219-06-202327-06-2023
FG03App0308-06-202329-06-2023
FG01App0423-05-202331-08-2023
FG02App0516-11-202313-12-2023
FG03App0601-11-202301-12-2023
FG01App0722-02-202420-03-2024
FG02App0822-02-202420-03-2024
FG03App0926-07-202405-09-2024
FG01App1022-11-202419-12-2024
FG02App1122-04-202415-06-2024
FG03App1220-02-202519-03-2025

@Vaibhav3008 Hi!
you need to create two measures, you can find the solution in the attached pbix
If I answered correctly, accept my answer as a solution, otherwise direct the problem to me and we will solve it!

BBF

Thanks for the all the help on this.

Currently the count is only taking start date into account. I need the count of apps falling in between start and end dates. Example - App11 should be counted in April 2024, May 2024 and June 2024 because the start and end dates are like that. Another example - App05 should be counted in November 2024 and December 2024.

@Vaibhav3008 Sorry!

Try with this new,

BBF

Thanks for the reply.

I am actually doing the same thing which you did here. But somehow it's not working.

As you can see in the pic below. The count for June 2023 should be atleast 4 (App01, App02, App03 and App04 all are falling inside June 2023). But the count in graph is coming as 1 only for June 2023.

Vaibhav3008_0-1696567485728.png

 

@Vaibhav3008 right, here the code adjusted

 

BBF

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

AugPowerBI_Carousel

Power BI Monthly Update - August 2024

Check out the August 2024 Power BI update to learn about new features.

August Carousel

Fabric Community Update - August 2024

Find out what's new and trending in the Fabric Community.