cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Ceane
Regular Visitor

Syntax error in new Measure (SUMX & FILTER)

Hi,  I'm new to PowerBI, but relatively profficient in excel. However no experience with DAX formulas.

I am creating a BI dashboard based on some financial data, and I'm trying to create a new measure using a combo of SUMX & FILTER functions, but clearly I don't understand the syntax properly. This is the situation.

 

I have a query that looks somthing like this:

CurrencyCost TypeDivisionLocationDateAmount
AUDTotal Employment CostChemistryAfrica1/01/2015500
AUDEBITBiologyEurope1/01/2015400
AUDNet RevenueScienceAsia1/01/2015300
AUDTECGardeningNorth America1/01/2015200
AUDEBITChemistrySouth America1/01/2015500
USDNet RevenueBiologyAfrica1/01/2015600
USDTECScienceEurope1/01/2015200
USDEBITGardeningAsia1/01/2015100
etcetcetcetcetcetc

Each location has an EBIT, TEC and Net Revenue Value, in USD & AUD.

 

I would like to create a new Measure (Cost Base) = Revenue - EBIT, and a second Measure (Other Costs) = Cost Base - TEC.

 

To do this I've tried:

Cost Base = sumx(filter('Cost Types','Cost Types'[Cost Type]=EBIT),'Cost Types'[Amount])  

 

But I keep getting errors.  I'm pretty sure they revolve around the "EBIT" but I'm not sure how to resolve. And I haven't even attempted the second part of the equation yet: do i do sumx - sumx?

 

The end goal is to create a stacked bar graph over time, with TEC:OtherCosts:EBIT where the total = revenue. This graph will be sliced by currency, division and location.

 

Is any of this possible?

1 ACCEPTED SOLUTION
v-huizhn-msft
Microsoft
Microsoft

Hi @Ceane,

As the @Phil_Seamark, if the data type is text, you should use "EBIT" rather than EBIT. For your requriement of 'Cost Base = Revenue - EBIT', the Revenue is Net Revenue, right? If it is, please create measure using the following formulas.

Cost Base = sumx(filter('Cost Types','Cost Types'[Cost Type]="Net Revenue"),'Cost Types'[Amount])-sumx(filter('Cost Types','Cost Types'[Cost Type]="EBIT"),'Cost Types'[Amount])

Other Costs = 'Cost Types'[Cost Base]- sumx(filter('Cost Types','Cost Types'[Cost Type]="TEC"),'Cost Types'[Amount])


Then create three slicer including currency, division and location seperately. Create a  a stacked bar graph, select the date as axis level, the Cost and Other Costs measures are value level, you will get the chart like the following screenshot.


Capture11.PNG

You can click the Format->Edit Interactions, edit if the slicer effect bar chart. When you hit button highlighted in yellow background, the slicer will effect the chart. Otherwise, the slicer doesn't effect chart when you select the circle(highlighted in red line).

Capture2.PNG

If you have any other problem, please let me know.

Best Regards,
Angelia

View solution in original post

2 REPLIES 2
v-huizhn-msft
Microsoft
Microsoft

Hi @Ceane,

As the @Phil_Seamark, if the data type is text, you should use "EBIT" rather than EBIT. For your requriement of 'Cost Base = Revenue - EBIT', the Revenue is Net Revenue, right? If it is, please create measure using the following formulas.

Cost Base = sumx(filter('Cost Types','Cost Types'[Cost Type]="Net Revenue"),'Cost Types'[Amount])-sumx(filter('Cost Types','Cost Types'[Cost Type]="EBIT"),'Cost Types'[Amount])

Other Costs = 'Cost Types'[Cost Base]- sumx(filter('Cost Types','Cost Types'[Cost Type]="TEC"),'Cost Types'[Amount])


Then create three slicer including currency, division and location seperately. Create a  a stacked bar graph, select the date as axis level, the Cost and Other Costs measures are value level, you will get the chart like the following screenshot.


Capture11.PNG

You can click the Format->Edit Interactions, edit if the slicer effect bar chart. When you hit button highlighted in yellow background, the slicer will effect the chart. Otherwise, the slicer doesn't effect chart when you select the circle(highlighted in red line).

Capture2.PNG

If you have any other problem, please let me know.

Best Regards,
Angelia

Phil_Seamark
Microsoft
Microsoft

Give this a crack

 

Cost Base = sumx(filter('Cost Types','Cost Types'[Cost Type]="EBIT"),'Cost Types'[Amount]) 


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Helpful resources

Announcements
PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

MPPC 2023 PBI Carousel

Power Platform Conference-Power BI and Fabric Sessions

Join us Oct 1 - 6 in Las Vegas for the Microsoft Power Platform Conference.

Top Solution Authors