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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Lucian
Responsive Resident
Responsive Resident

How to compare values (calculate diferences) from the same colum as were two colums

Hello,

 

I have a report requirement, for which I cannot find a way to achieve it, if possible, in Power BI Desktop.

The raw data is in Excel and after combining multiple source files it look like this:

DataTable.jpg

 

Because I don't have the option to upload files I will put the raw data as CSV:

Year,Project,CostCenter,Cost
FY_2010,A,C1,1000
FY_2010,A,C1,500
FY_2010,A,C2,500
FY_2010,B,C1,1000
FY_2010,C,C2,1000
FY_2011,A,C1,1500
FY_2011,A,C1,500
FY_2011,B,C1,1500
FY_2011,C,C1,1000
FY_2012,A,C1,2000
FY_2012,A,C1,1000
FY_2012,B,C1,2000
FY_2012,C,C2,1500

The Cost colum is the only numeric colum that will imply calculations. The Year colum even is related to a certain period of time, is just a "text label".

The report should allow the user select only two YEAR values, and I should identify which is FIRST/SECOND selection because after selection I have to do some calculations between them. For example make a simple diference SECOND-FIRST.

 

The final table should look like this:

 

FinalTable.jpg

 

The hard part for me is to have in this final table "dynamic colum names" because I have to see which are the selected Years.

I have partially achieved this with two calculated measures based on two slicers and renaming the table columns manually after user selection, but it has to be dynamic. I cannot use matrix visual because of the measures.

 

Is there a way to have a table with dynamic column names? - if I can rename column manually is there a way to dynamically create the name of the column based on the slicer selection?

 

Is there another way to achieve this goal? Because of the fixed format for the final table, any suggestion is welcomed (even reorganizing data).

 

Kind Regards,

Lucian

1 ACCEPTED SOLUTION
sturlaws
Resident Rockstar
Resident Rockstar

Hi @Lucian,

 

Power BI does not support dynamic naming of measures. There are a couple of workarounds:
-You can use the R-visual or Python-visual.

-You can create measures which returns the names you want for the measures and show them in card visuals. Then set the table header color to white, and overlay the table headers with the cards

 

cheers,

Sturla

View solution in original post

3 REPLIES 3
sturlaws
Resident Rockstar
Resident Rockstar

Hi @Lucian,

 

Power BI does not support dynamic naming of measures. There are a couple of workarounds:
-You can use the R-visual or Python-visual.

-You can create measures which returns the names you want for the measures and show them in card visuals. Then set the table header color to white, and overlay the table headers with the cards

 

cheers,

Sturla

Lucian
Responsive Resident
Responsive Resident

Hi @sturlaws ,

 

And thank you for your time. Unfortunately I don't know too much about R-visuals or Python-visuals, but I'm a "fast learner" and if you could help me with the code to create the reduced table model from above picture, I might find a way to reproduce it for my real table. Smiley Wink

 

Until then I will use the card visuals, but in this case I will loose the sorting option and "focus mode" for this visual.

 

Meanwhile I post an ideea, and if voted, maybe we all benefit from it: Improved table visual - dynamic column names  

@Lucian,

 

yes, you are quite right, the cards solution is a work-around with limited functionality.

 

R and python will be better, but they kind of don't look like power bi. I occasionall dabble in R, and know enough about it to know that I should not advise others on how to do it. I can only give you a pointer: https://docs.microsoft.com/en-us/power-bi/desktop-r-visuals

 

Perhaps you will find answers elsewhere in the forum

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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