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
Syndicate_Admin
Administrator
Administrator

Clasificación de columnas mes-año de Desc a Asc

Hola

Tengo la columna Mes Año en 2022-Enero, 2022-Marzo este formato

Cuando saco esta columna en Matrix, entonces quiero ordenar esta columna de desc a asc

2 REPLIES 2
Syndicate_Admin
Administrator
Administrator

Hi, @bilalkhokar73 ,

Puede agregar una columna de índice ordenada por año-mes.

1.agregar índice en power query.group

vyalanwumsft_6-1657094651035.png

2.ordenar

vyalanwumsft_2-1657093955328.png

3.agregar columna de índice y expandirla.

vyalanwumsft_3-1657093973281.png

A continuación, ordene por columna de índice.

vyalanwumsft_4-1657094279966.png

El espectáculo final:

vyalanwumsft_5-1657094296988.png

let
 Source = Excel.Workbook(File.Contents("C:\Program Files\Microsoft Power BI Desktop\bin\SampleData\Financial Sample.xlsx"), null, true),
    financials_Table = Source{[Item="financials",Kind="Table"]}[Data],
    #"Changed Type" = Table.TransformColumnTypes(financials_Table,{{"Segment", type text}, {"Country", type text}, {"Product", type text}, {"Discount Band", type text}, {"Units Sold", type number}, {"Manufacturing Price", Int64.Type}, {"Sale Price", Int64.Type}, {"Gross Sales", type number}, {"Discounts", type number}, {" Sales", type number}, {"COGS", type number}, {"Profit", type number}, {"Date", type date}, {"Month Number", Int64.Type}, {"Month Name", type text}, {"Year", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Y-month", each Date.ToText([Date],"yyyy-MMM")),
    #"Grouped Rows" = Table.Group(#"Added Custom", {"Year", "Month Number"}, {{"A", each _, type table [Segment=nullable text, Country=nullable text, Product=nullable text, Discount Band=nullable text, Units Sold=nullable number, Manufacturing Price=nullable number, Sale Price=nullable number, Gross Sales=nullable number, Discounts=nullable number, #" Sales"=nullable number, COGS=nullable number, Profit=nullable number, Date=nullable date, Month Number=nullable number, Month Name=nullable text, Year=nullable number, #"Y-month"=text]}}),
    #"Sorted Rows" = Table.Sort(#"Grouped Rows",{{"Year", Order.Descending}, {"Month Number", Order.Descending}}),
    #"Added Index" = Table.AddIndexColumn(#"Sorted Rows", "Index", 1, 1, Int64.Type),
    #"Expanded A" = Table.ExpandTableColumn(#"Added Index", "A", {"Segment", "Country", "Product", "Discount Band", "Units Sold", "Manufacturing Price", "Sale Price", "Gross Sales", "Discounts", " Sales", "COGS", "Profit", "Date", "Y-month"}, {"Segment", "Country", "Product", "Discount Band", "Units Sold", "Manufacturing Price", "Sale Price", "Gross Sales", "Discounts", " Sales", "COGS", "Profit", "Date", "Y-month"})
in
    #"Expanded A"


Saludos
Equipo de soporte de la comunidad _ Yalan Wu
Si esta publicación ayuda, considere Aceptarla como la solución para ayudar a los otros miembros a encontrarla más rápidamente.

Syndicate_Admin
Administrator
Administrator

Hola
Cree una columna personalizada con Date.ToText([Date], "aaaaMM") y use esta columna para ordenar la columna Mes Año

Pls referirse a:

https://radacad.com/generate-year-month-day-combinations-in-power-bi-report-using-power-query-date-t...

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.