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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

How to make line chart to show quarterly count of dates.

I'm new to Power BI and i'm having a hard time navigating all the different options. So any help would be appreciated.

 

I have columns that holds the "client's name" and dates that are split into quarters by year. The date represent when the client's account was worked on. Let's say that there are never more than 1 date in a quarter. 

 

Ex.

 

      
 2017 quarter 12017 quarter 22017 quarter 32017 quarter 42018 quarter 1
Tom1/1/20175/2/2017 12/1/20172/1/2018
Eric1/1/2017 7/1/201712/1/2017 
Sarah1/1/2017    
Lisa1/1/2017  12/2/20171/1/2018

 

How do i get the line chart to show how many acounts were worked on in a year by the quarter or month?

From the example, 2017 quarter 1 will have a count of 4, quarter 2 will have 1....and so on.

 

Thanks!

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

Hi @Anonymous,

 

I made one sample for your reference.

 

1. Transform the table in the query editor. M code for your reference.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCsnPVdJRMtQ31DcyMDQHMk31jWBMBZCMEUIKyrRQitWJVnItykxG1QlSbo7gIutUAGsJTixKzMDUg8AgRT6ZxYnY1QANhDvNEO6UWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"Client name" = _t, #"2017 quarter 1" = _t, #"2017 quarter 2" = _t, #"2017 quarter 3" = _t, #"2017 quarter 4" = _t, #"2018 quarter 1" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Client name", type text}, {"2017 quarter 1", type date}, {"2017 quarter 2", type date}, {"2017 quarter 3", type date}, {"2017 quarter 4", type date}, {"2018 quarter 1", type date}}),
    #"Demoted Headers" = Table.DemoteHeaders(#"Changed Type"),
    #"Changed Type1" = Table.TransformColumnTypes(#"Demoted Headers",{{"Column1", type text}, {"Column2", type any}, {"Column3", type any}, {"Column4", type any}, {"Column5", type any}, {"Column6", type any}}),
    #"Transposed Table" = Table.Transpose(#"Changed Type1"),
    #"Promoted Headers" = Table.PromoteHeaders(#"Transposed Table", [PromoteAllScalars=true]),
    #"Changed Type2" = Table.TransformColumnTypes(#"Promoted Headers",{{"Client name", type text}, {"Tom", type date}, {"Eric", type date}, {"Sarah", type date}, {"Lisa", type date}})
in
    #"Changed Type2"

1.PNG

 

2. Create four calculated columns in the fact table.

 

Tomc = IF(ISBLANK(Table1[Tom]),0,1)
Eri = IF(ISBLANK(Table1[Eric]),0,1)
sar = IF(ISBLANK(Table1[Sarah]),0,1)
Lis = IF(ISBLANK(Table1[Lisa]),0,1)

3. Create a measure to achieve our goal.

 

Measure = SUM(Table1[Eri])+SUM(Table1[Lis])+SUM(Table1[sar])+SUM(Table1[Tomc])

Capture.PNG

 

For more details, please check the pbix as attached.

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

3 REPLIES 3
v-frfei-msft
Community Support
Community Support

Hi @Anonymous,

 

I made one sample for your reference.

 

1. Transform the table in the query editor. M code for your reference.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCsnPVdJRMtQ31DcyMDQHMk31jWBMBZCMEUIKyrRQitWJVnItykxG1QlSbo7gIutUAGsJTixKzMDUg8AgRT6ZxYnY1QANhDvNEO6UWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"Client name" = _t, #"2017 quarter 1" = _t, #"2017 quarter 2" = _t, #"2017 quarter 3" = _t, #"2017 quarter 4" = _t, #"2018 quarter 1" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Client name", type text}, {"2017 quarter 1", type date}, {"2017 quarter 2", type date}, {"2017 quarter 3", type date}, {"2017 quarter 4", type date}, {"2018 quarter 1", type date}}),
    #"Demoted Headers" = Table.DemoteHeaders(#"Changed Type"),
    #"Changed Type1" = Table.TransformColumnTypes(#"Demoted Headers",{{"Column1", type text}, {"Column2", type any}, {"Column3", type any}, {"Column4", type any}, {"Column5", type any}, {"Column6", type any}}),
    #"Transposed Table" = Table.Transpose(#"Changed Type1"),
    #"Promoted Headers" = Table.PromoteHeaders(#"Transposed Table", [PromoteAllScalars=true]),
    #"Changed Type2" = Table.TransformColumnTypes(#"Promoted Headers",{{"Client name", type text}, {"Tom", type date}, {"Eric", type date}, {"Sarah", type date}, {"Lisa", type date}})
in
    #"Changed Type2"

1.PNG

 

2. Create four calculated columns in the fact table.

 

Tomc = IF(ISBLANK(Table1[Tom]),0,1)
Eri = IF(ISBLANK(Table1[Eric]),0,1)
sar = IF(ISBLANK(Table1[Sarah]),0,1)
Lis = IF(ISBLANK(Table1[Lisa]),0,1)

3. Create a measure to achieve our goal.

 

Measure = SUM(Table1[Eri])+SUM(Table1[Lis])+SUM(Table1[sar])+SUM(Table1[Tomc])

Capture.PNG

 

For more details, please check the pbix as attached.

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
Anonymous
Not applicable

Hello @v-frfei-msft,

 

Stop the meaure below in step 3, do you know if there is a quicker way to create that if i have 1,000 clients? It'll be okay to type out 4 clients but I don't think typing out 1,000 clients are ideal. Your help would be appreciate!

 

Thank you,

Nina

Anonymous
Not applicable

This is perfect, thank you!

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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