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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

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 Employee
Microsoft Employee

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 Employee
Microsoft Employee

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 Employee
Microsoft Employee

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.