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
shubh_kush
Helper I
Helper I

How to use Calculated column values with measures ?

Hi all,

I have a column Cost_Percentage and a measure Base_Percentage. DAX for Base_Percentage is as follows:

Base_Percentage =  IF(HASONEVALUE('Table_A'[Percentage_Base_Change]), VALUES('Table_A'[Percentage_Base_Change]), 0)

I am using this Base_Percentage measure in slicer so that user can select the specific percentage. 

 

I want to subtract Cost_Percentage and Base_Percentage (Whatever user selects).

Say if user selects Base_Percentage = 30 from the slicer,  then values in the column Cost_Percentage should be subtracted by 30.

But I cannot use Cost_Percentage with Base_Percentage in the measure directly .

 

Say, Measure_1 = (Cost_Percentage - Base_Percentage),  How can I read all single rows values of the column Cost_Percentage and subtract it from the measure Base_Percentage for which the user will select the value from the slicer?

The logic is quite large but for now I just want to know how can I use the column in the measure for some mathematical expression.

 

Thanks in Advance.

1 REPLY 1
amitchandak
Super User
Super User

@shubh_kush , You can not create a column with measure. You have to create measure and force context at like level

 

new measure

sumx(values(Table[ID]) , sum(Table[Cost_Percentage]) -[Base_Percentage])

Assuming ID is at the lowest level.

 

if not then try like

sumx(values(Table[ID]) , sum(Table[Cost_Percentage]) -[Base_Percentage]*count(Table[ID]))

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.