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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

Does anyone know how to create a date value for each row and divide into 3 values based on quarters

Hello, this is my table.  

Region ProductSub-productAttributeValue
Czech RepublicFurnitureChairQ112899
Czech RepublicFurnitureChairQ215929
Czech RepublicFurnitureChairQ312123
Czech RepublicFurnitureChairQ412093

How do I convert from this table to this one? Splitting quaters into 3, there should be month column.

Region ProductSub-productAttributeValue  Month/Date
Czech RepublicFurnitureChairQ14299.7  2022.01.01
Czech RepublicFurnitureChairQ14299.7  2022.02.01
Czech RepublicFurnitureChairQ14299.7  2022.03.01
Czech RepublicFurnitureChairQ25309.7  2022.04.01
Czech RepublicFurnitureChairQ25309.7  2022.05.01
Czech RepublicFurnitureChairQ25309.7  2022.06.01

and so on. I have different countries, products and subproduct as well. 

How do I achieve this on Power Query?

Thanks for your support.

1 ACCEPTED SOLUTION
ImkeF
Super User
Super User

Hi @Anonymous ,
you can extract the number part from the quarter-column and then create a list of months based on that.
Expand that list out and divide by 3 to get monthly values:

// Table1
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Region ", type text}, {"Product", type text}, {"Sub-product", type text}, {"Attribute", type text}, {"Value", Int64.Type}}),
    InsertBase = Table.AddColumn(#"Changed Type", "Base", each Number.From(Text.AfterDelimiter([Attribute], "Q")), type number),
    #"Added Custom" = Table.AddColumn(InsertBase, "Months", each {([Base]*3-2) .. [Base]*3}),
    #"Expanded Months" = Table.ExpandListColumn(#"Added Custom", "Months"),
    #"Added Custom1" = Table.AddColumn(#"Expanded Months", "MonthlyValue", each [Value]/3)
in
    #"Added Custom1"

Please also check file enclosed.

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

View solution in original post

1 REPLY 1
ImkeF
Super User
Super User

Hi @Anonymous ,
you can extract the number part from the quarter-column and then create a list of months based on that.
Expand that list out and divide by 3 to get monthly values:

// Table1
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Region ", type text}, {"Product", type text}, {"Sub-product", type text}, {"Attribute", type text}, {"Value", Int64.Type}}),
    InsertBase = Table.AddColumn(#"Changed Type", "Base", each Number.From(Text.AfterDelimiter([Attribute], "Q")), type number),
    #"Added Custom" = Table.AddColumn(InsertBase, "Months", each {([Base]*3-2) .. [Base]*3}),
    #"Expanded Months" = Table.ExpandListColumn(#"Added Custom", "Months"),
    #"Added Custom1" = Table.AddColumn(#"Expanded Months", "MonthlyValue", each [Value]/3)
in
    #"Added Custom1"

Please also check file enclosed.

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.

Top Solution Authors
Top Kudoed Authors