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

Preparing for a certification exam? Ask exam experts all your questions on May 15th. Register now.

Reply
HaroldqPants
Regular Visitor

Create a measure from Column Values

Hi Forum,
I have some data in an odd format, most columns are what you would expect, but one Column 'KPIs' contains the Values 'Units' & 'Sales'.
There's also measures in another Column 'Actuals' for the 'Units' & 'Sales' figures.
I can transpose the  'KPIs' Column and get the 'Actuals' for 'Units' & 'Sales', the problem is that I want to create a new Column from this transposed data to do a calculation like 'Sales' divided by 'Units'.
Any suggestions welcome.
Thanks

ProductKPIsActuals
Product1Units231
Product1Sales1346
Product2Units245
Product2Sales3426
Product3Units546
Product3Sales45278
Product4Units378
Product4Sales7642
Product5Units299
Product5Sales84332
2 ACCEPTED SOLUTIONS
rajendraongole1
Super User
Super User

Hi @HaroldqPants - In power query editor

Go to the Transform tab, and click on Pivot Column.
In the Pivot Column dialog, select 'KPIs' as the column to pivot, and 'Actuals' as the values column.
For the Advanced options, choose Don't Aggregate.

Reference:

rajendraongole1_0-1717565515963.png

Go to the Add Column tab and click on Custom Column.

 

rajendraongole1_1-1717565653830.png

Click close & Apply to return to the Power BI report view.

 

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

Anonymous
Not applicable

Hi @HaroldqPants ,

@rajendraongole1 Good Answer!
And @HaroldqPants Not all data sources can use Power Query, it depends on your connection mode. Only in Import mode can you fully use Power Query. If you are in Direct Query mode, your Power Query will be limited, some functions cannot be used, and some data is not visible to you. If you are in Live Connection mode, you cannot use Power Query. In addition, if the data table is a calculated column or a calculated table, it is not visible in Power Query.
I can provide you with a method using DAX to achieve your needs.
Use the following DAX to create a measure:

'Sales' divided by 'Units'_measure = 
VAR _CurrentProduct = MAX('Table'[Product])
VAR _Sales = 
CALCULATE(
    SUM('Table'[Actuals]),
    ALL('Table'),
    'Table'[Product] = _CurrentProduct && 'Table'[KPIs] = "Sales"
)
VAR _Units = 
CALCULATE(
    SUM('Table'[Actuals]),
    ALL('Table'),
    'Table'[Product] = _CurrentProduct && 'Table'[KPIs] = "Units"
)
RETURN
DIVIDE(_Sales, _Units)


Use the following DAX to create a calculated column:

'Sales' divided by 'Units' = 
VAR _CurrentProduct = 'Table'[Product]
VAR _Sales = 
CALCULATE(
    SUM('Table'[Actuals]),
    ALL('Table'),
    'Table'[Product] = _CurrentProduct && 'Table'[KPIs] = "Sales"
)
VAR _Units = 
CALCULATE(
    SUM('Table'[Actuals]),
    ALL('Table'),
    'Table'[Product] = _CurrentProduct && 'Table'[KPIs] = "Units"
)
RETURN
DIVIDE(_Sales, _Units)

And the final output is as below:

vjunyantmsft_2-1717642337159.png


Best Regards,
Dino Tao
If this post helps, then please consider Accept both of the answers as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi @HaroldqPants ,

@rajendraongole1 Good Answer!
And @HaroldqPants Not all data sources can use Power Query, it depends on your connection mode. Only in Import mode can you fully use Power Query. If you are in Direct Query mode, your Power Query will be limited, some functions cannot be used, and some data is not visible to you. If you are in Live Connection mode, you cannot use Power Query. In addition, if the data table is a calculated column or a calculated table, it is not visible in Power Query.
I can provide you with a method using DAX to achieve your needs.
Use the following DAX to create a measure:

'Sales' divided by 'Units'_measure = 
VAR _CurrentProduct = MAX('Table'[Product])
VAR _Sales = 
CALCULATE(
    SUM('Table'[Actuals]),
    ALL('Table'),
    'Table'[Product] = _CurrentProduct && 'Table'[KPIs] = "Sales"
)
VAR _Units = 
CALCULATE(
    SUM('Table'[Actuals]),
    ALL('Table'),
    'Table'[Product] = _CurrentProduct && 'Table'[KPIs] = "Units"
)
RETURN
DIVIDE(_Sales, _Units)


Use the following DAX to create a calculated column:

'Sales' divided by 'Units' = 
VAR _CurrentProduct = 'Table'[Product]
VAR _Sales = 
CALCULATE(
    SUM('Table'[Actuals]),
    ALL('Table'),
    'Table'[Product] = _CurrentProduct && 'Table'[KPIs] = "Sales"
)
VAR _Units = 
CALCULATE(
    SUM('Table'[Actuals]),
    ALL('Table'),
    'Table'[Product] = _CurrentProduct && 'Table'[KPIs] = "Units"
)
RETURN
DIVIDE(_Sales, _Units)

And the final output is as below:

vjunyantmsft_2-1717642337159.png


Best Regards,
Dino Tao
If this post helps, then please consider Accept both of the answers as the solution to help the other members find it more quickly.

Thanks Dino,

Apologies for the delayed response. I'll try this and come back to you.

Appreciate the effort you went to, thanks again.

rajendraongole1
Super User
Super User

Hi @HaroldqPants - In power query editor

Go to the Transform tab, and click on Pivot Column.
In the Pivot Column dialog, select 'KPIs' as the column to pivot, and 'Actuals' as the values column.
For the Advanced options, choose Don't Aggregate.

Reference:

rajendraongole1_0-1717565515963.png

Go to the Add Column tab and click on Custom Column.

 

rajendraongole1_1-1717565653830.png

Click close & Apply to return to the Power BI report view.

 

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Thanks rajendraongole1,

I've got the example data in a Table in Power BI Desktop but when I go to Transform, the data isn't there?

Sorry to ask such a bsaic question but how do I see my table in the Transform pane? 

Hi @HaroldqPants - You have to extract the data from the table source system to Power BI and  then navigate the power query editor transform data. 

 

if you are already connected the data, check the permission are there with your name?

 

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

Spoiler
 

 

 

 

 

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
PBIApril_Carousel

Power BI Monthly Update - April 2025

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

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

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