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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Vito
Helper I
Helper I

Summarisation of two tables and linkage within script environment

I am in a situation whereby I had to create to actual table:

CCSumm2022 =
var CC2021 = SUMMARIZE(CCDatabase,CCDatabase[COST_ELEMENT_NAME], CCDatabase[Key], "Cost 2021",sum(CCDatabase[Value]))
var CC2022v = SUMMARIZE(CC2022,CC2022[Cost element name],CC2022[Key],"Cost 2022", sum(CC2022[Value]))
return CC2022v and return CC2021
 
then I had to 
add a column to CC2022v via:
Cost 2021 = LOOKUPVALUE(CCSumm2021[Cost 2021],CCSumm2021[Key],CCSumm2022[Key])
 
Final result was:
Vito_0-1674661503285.png

 

As I have to do the same with other databases that has 2022 and 2021 records, I was trying something like

CCSumm2022 =
var CC2021 = SUMMARIZE(CCDatabase,CCDatabase[COST_ELEMENT_NAME], CCDatabase[Key], "Cost 2021", sum(CCDatabase[Value]))
var CC2022v = SUMMARIZE(CC2022,CC2022[Cost element name],CC2022[Key],"Cost 2022", sum(CC2022[Value]))
return ADDCOLUMNS(CC2022v, "Cost 2021", LOOKUPVALUE(CCSumm2021[Cost 2021],CCSumm2021[Key],CCSumm2022[Key]))
 
In doing so I was trying to create the two summarised table as variables, lookup the 2021 value by using the key and add it to CC2022v table used to produce the chart.
 
It did not work. Is there a way to add a new column on a variable from another variable on the fly?
Thank you for helping
1 REPLY 1
v-shex-msft
Community Support
Community Support

Hi @Vito,

Can you please share a pbix or some dummy data that keep the raw data structure with expected results? It should help us clarify your scenario and test to coding formula.

How to Get Your Question Answered Quickly  

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.