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

July 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more

Reply
alfredorhz
Helper I
Helper I

Help With Cross data

Hi Power bi Community
I need some help, How can solve this by dax? I need to create a measure where find the values in yellow, and put it in a column, crossing row month with column month


thank you very much

alfredorhz_1-1657152688256.png

 

 

2 ACCEPTED SOLUTIONS

*********************************************************************************************************
let
Source = Excel.Workbook(File.Contents("Enter your data source path here"), null, true),
Base_Sheet = Source{[Item="Base",Kind="Sheet"]}[Data],
#"Promoted Headers" = Table.PromoteHeaders(Base_Sheet, [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"mont year", type text}, {"mon mun", Int64.Type}, {"JAN", Int64.Type}, {"FEB", Int64.Type}, {"MAR", Int64.Type}, {"APR", Int64.Type}, {"MAY", Int64.Type}}),
#"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"mont year", "mon mun"}, "Atribute", "Value"),
#"Grouped Rows" = Table.Group(#"Unpivoted Columns", {"mon mun"}, {{"Group", each _, type table [mont year=nullable text, mon mun=nullable number, Atributo=text, Valor=number]}}),
#"Added Custom" = Table.AddColumn(#"Grouped Rows", "TableList", each Table.AddIndexColumn([Group],"Index",1,1)),
#"Removed Other Columns" = Table.SelectColumns(#"Added Custom",{"TableList"}),
#"Expanded {0}" = Table.ExpandTableColumn(#"Removed Other Columns", "TableList", {"mont year", "mon mun", "Atribute", "Value", "Index"}, {"mont year", "mon mun", "Atribute", "Value", "Index"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Expanded {0}",{{"mont year", type text}, {"mon mun", Int64.Type}, {"Atribute", type text}, {"Value", Int64.Type}, {"Index", Int64.Type}}),
#"Added Conditional Column" = Table.AddColumn(#"Changed Type1", "Action", each if [mon mun] = [Index] then "Keep" else "Remove"),
#"Filtered Rows" = Table.SelectRows(#"Added Conditional Column", each ([Action] = "Keep"))
in
#"Filtered Rows"
*********************************************************************************************************
Did I solve your problem?
Please mark as solution so others can find this solution.
https://www.linkedin.com/in/rodrigosanpbi/

View solution in original post

Hi,

In the Query Editor, remove the mon mun column.  Right click on the first column and select "Unpivot Other Columns".  Write an If function then to check whether the first column = attribute column.  Filter this new column on true. 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

9 REPLIES 9
Ashish_Mathur
Super User
Super User

Hi,

How is your source data table arranged?  Share that in a format that can be pasted in an MS Excel file.  Also, would you be OK with an M language solution as well?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi Ashish!
Thanks for reply
It is in that right format in excel, I'm not very skilled with M language, but I´m open to a solution over M.
Thank you very much

Hi,

In the Query Editor, remove the mon mun column.  Right click on the first column and select "Unpivot Other Columns".  Write an If function then to check whether the first column = attribute column.  Filter this new column on true. 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thank you Ashish, I tried this solution, and works too

You are welcome.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
rodrigosan
Responsive Resident
Responsive Resident

This deal can be done in Power Query directly

Thanks, RodrigoSan

how I could do that?

*********************************************************************************************************
let
Source = Excel.Workbook(File.Contents("Enter your data source path here"), null, true),
Base_Sheet = Source{[Item="Base",Kind="Sheet"]}[Data],
#"Promoted Headers" = Table.PromoteHeaders(Base_Sheet, [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"mont year", type text}, {"mon mun", Int64.Type}, {"JAN", Int64.Type}, {"FEB", Int64.Type}, {"MAR", Int64.Type}, {"APR", Int64.Type}, {"MAY", Int64.Type}}),
#"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"mont year", "mon mun"}, "Atribute", "Value"),
#"Grouped Rows" = Table.Group(#"Unpivoted Columns", {"mon mun"}, {{"Group", each _, type table [mont year=nullable text, mon mun=nullable number, Atributo=text, Valor=number]}}),
#"Added Custom" = Table.AddColumn(#"Grouped Rows", "TableList", each Table.AddIndexColumn([Group],"Index",1,1)),
#"Removed Other Columns" = Table.SelectColumns(#"Added Custom",{"TableList"}),
#"Expanded {0}" = Table.ExpandTableColumn(#"Removed Other Columns", "TableList", {"mont year", "mon mun", "Atribute", "Value", "Index"}, {"mont year", "mon mun", "Atribute", "Value", "Index"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Expanded {0}",{{"mont year", type text}, {"mon mun", Int64.Type}, {"Atribute", type text}, {"Value", Int64.Type}, {"Index", Int64.Type}}),
#"Added Conditional Column" = Table.AddColumn(#"Changed Type1", "Action", each if [mon mun] = [Index] then "Keep" else "Remove"),
#"Filtered Rows" = Table.SelectRows(#"Added Conditional Column", each ([Action] = "Keep"))
in
#"Filtered Rows"
*********************************************************************************************************
Did I solve your problem?
Please mark as solution so others can find this solution.
https://www.linkedin.com/in/rodrigosanpbi/

Thanks, RodrigoSan, works perfect

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

Check out the July 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors