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
Kish1999
Helper II
Helper II

Count the Number of Project for Each Month

Hello All,

 

I have requirement where I want to count the number of Projects in a particular status Month Over Month. Below is the sample dataset.

ProjectCreated DateModified dateStatus
    
A01-02-202001-02-2020Green
A01-02-2020

04-04-20

20

Red
A01-02-202007-08-2020Amber
B02-02-202002-02-2020Green
B02-02-202004-07-2020Amber
C03-02-202003-02-2020Green
C03-02-202007-02-2020Amber
C03-02-202020-02-2020Red

 

The requirement is to Count the Prjects with Red,Amber,Green status for each month. If the project status changes multiple times within a month, we should count the latest status. Below is the sample result:

 

Result:   
MonthGreenAmberRed
Feb-20201
Mar-20201
Apr-20102
May-20102
Jun-20102
Jul-20102
Aug-20111
1 ACCEPTED SOLUTION
v-rongtiep-msft
Community Support
Community Support

Hi @Kish1999,

Please have a try.

Modify the data foramt.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTLSN9Q3MjAyQGW6F6Wm5inF6mCoMdE3gTGDUlOwqbDQN4cxHXOTUovAapzAaowQNhlh2oSmxhxhE8IcZ7AaY4Q5xpjmYKjB4h4MNUYGKN6KBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Project = _t, #"Created Date" = _t, #"Modified date" = _t, Status = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Project", type text}, {"Created Date", type date}, {"Modified date", type date}, {"Status", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if 
List.Count(
List.Select(
List.Dates([Created Date],Duration.Days([Modified date]-[Created Date])+1,#duration(1,0,0,0)),each Date.Day(_)=1))
= 0 
then {[Modified date]}
else List.Select(
List.Dates([Created Date],Duration.Days([Modified date]-[Created Date])+1,#duration(1,0,0,0)),each Date.Day(_)=1)),
    #"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom"),
    #"Changed Type1" = Table.TransformColumnTypes(#"Expanded Custom",{{"Custom", type date}})
in
    #"Changed Type1"

Then create measures.

Measure3 =
MAXX (
    FILTER (
        ALL ( 'Table' ),
        'Table'[Project] = SELECTEDVALUE ( 'Table'[Project] )
            && 'Table'[Column] = SELECTEDVALUE ( 'Table'[Column] )
    ),
    [Measure2]
)

vrongtiepmsft_1-1684299149831.png

How to Get Your Question Answered Quickly 

 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Rongtie

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

1 REPLY 1
v-rongtiep-msft
Community Support
Community Support

Hi @Kish1999,

Please have a try.

Modify the data foramt.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTLSN9Q3MjAyQGW6F6Wm5inF6mCoMdE3gTGDUlOwqbDQN4cxHXOTUovAapzAaowQNhlh2oSmxhxhE8IcZ7AaY4Q5xpjmYKjB4h4MNUYGKN6KBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Project = _t, #"Created Date" = _t, #"Modified date" = _t, Status = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Project", type text}, {"Created Date", type date}, {"Modified date", type date}, {"Status", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if 
List.Count(
List.Select(
List.Dates([Created Date],Duration.Days([Modified date]-[Created Date])+1,#duration(1,0,0,0)),each Date.Day(_)=1))
= 0 
then {[Modified date]}
else List.Select(
List.Dates([Created Date],Duration.Days([Modified date]-[Created Date])+1,#duration(1,0,0,0)),each Date.Day(_)=1)),
    #"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom"),
    #"Changed Type1" = Table.TransformColumnTypes(#"Expanded Custom",{{"Custom", type date}})
in
    #"Changed Type1"

Then create measures.

Measure3 =
MAXX (
    FILTER (
        ALL ( 'Table' ),
        'Table'[Project] = SELECTEDVALUE ( 'Table'[Project] )
            && 'Table'[Column] = SELECTEDVALUE ( 'Table'[Column] )
    ),
    [Measure2]
)

vrongtiepmsft_1-1684299149831.png

How to Get Your Question Answered Quickly 

 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Rongtie

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

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.