SUM IF in Power BI - powerbi

Is it possible to SUM on conditions in Power BI?
I have a column that contains the values UK and Italy alongside other columns: employee and hours spent.
I want to make a measure to show total hours spent by an employee in Italy and another to show total hours spent by an employee in UK.
I am having no luck with the DAX language. Can anyone help?

Yes. There are two basic approaches to this.
CALCULATE(SUM(TableName[Hours]), TableName[Country] = "Italy")
or
SUMX(FILTER(TableName, TableName[Country] = "Italy"), TableName[Hours])

Related

Having trouble getting a cumulative saving measure for a plot in PowerBi

As the title says, I can't sum [savings] cumulatively. My total savings measure only plots monthly saving not cumulative. Any help with the Dax for the measure would be greatly appreciated, I've tried a lot of solutions online to no avail.
Cheers
Power BI has a Quick Measure "Running Total" that is provided for exactly this purpose. Make sure you have a separate Date table and use that in the Field section.

PowerBI: Calculating Margin net of Labour

I am new to Powerbi and needed some help on creating a dax calculation.
Objective: calculate the margin net of labour costs.
I already have a table that contains the margin$(price - cost).
Regarding labour info:
the fixed wage rate is $17.00
During the week the number of hours worked is 9/ per weekday
on saturday the number of hours worked is 8
on sunday the number of hours worked is 6
I want to create a function that tells me the labour cost for a given day and overall labour cost should sum as each day passes.
I figured I should create specific variables in DAX but following that is were I am confused.
How do I dictate to powerbi the hours and rate to apply? any guidance?
|rate:17.00|
|weekdayhours: 9|
|sathours: 8|
|sunhours: 6|

Looking for DAX formula to calculate percentage per category for a year for a multiple choice ques

I have done almost everything but not able to achieve the desired solution.
I have two surveys for 2020 and 2021 which have multiple-choice questions.
So there are two tables:
Table 1
Table 2
Since it's a multiple-choice question, I want to calculate the percentage of respondents who chose e.g. western Europe as an attractive region based on total number of respondents for a survey. For this, I have linked the above two charts using Survey ID.
I want a measure to calculate the last column in below table 3:
Table 3
For eg. for Western Europe, 3 respondents in 2021 survey have marked it as a attractive region. Now the percentage I want is 3 divided by 4 (respondents in 2021 survey). The percentage I am getting is 3/9 (respondents in 2020+2021 survey)
This is the DAX I am using:
Denominator = calculate(sum('Table 2'[Weightage]),allexcept('Table 2',Table 2[Survey year]))
%category = divide(sum('Table 1'[Weightage]),Denominator,0)
Please suggest the change in DAX function to require desired percentage. Since its a multiple choice question I am facing issues. I really need this to be resolved, please suggest what can be done. Thankyou.

How to Calculate Variance with PowerBI DAX Waterfall Chart

I've sifted through threads and videos trying examples, but I still seem to be stuck. Please help? DAX newbie here.
I have a data set with yearly sales with granularity by geography, device type, and another column with ~6 different technical specifications. I would like to display a dynamic waterfall chart that shows yearly changes in sales based on selected slicers/filters in the workbook.
1) Resolve in one step
=CALCULATE(SUM(Data[$]))-CALCULATE(SUM(Data[$]),PARALLELPERIOD(Data[Date],-1,YEAR))
2) Create an intermediate value for last year sales and subtract from this year's sales
LY Sales = CALCULATE(SUM(Data[$]),DATEADD(Data[Date],-1,YEAR))
VARIANCE = [$] - [LY Sales]

Open Office find all bills labelled POWER and work average cost

So I have made a spreedsheet to help me keep track of my power and gas bill - well the total cost of the bill anyway. This way as the months go on I am able to see what the average Power and Gas bill have been.
I am using only sheet1 and prefer to do it this way, so when I show my partner they don't need to flick through pages of numbers. It's right in front of them with Power & Gas in the next row - take a look at the image below.
So as you can see from the above (not including the J3 row) I have everything laid out in the layout I would like. This way when I get a bill emailed to me I add it, and then I can pay X amount and record that.
I know how to do =sum() and =average() but how can I limit it to only the power rows automatically.
The query should be looking up G column for power or gas and then whichever one it is get the H column next to it and then work out the cost per month by looking at the date the bill came out.
Power bill is every month so that easy, gas is every 3 months.
I know in open office they have the =if() command and I made it return TRUE when it was power but it does not seem that i can use just that function? I am wondering if maybe a TUT or example that outlines how we get the result like this.
Another example would be replace gas and power with tech toys i.e batteries over a year what was the real cost per monthly.
Ok after thinking outside the square - the answer I am using is this.
=AVERAGEIF(G3:G100;"POWER";H3:H100)/COUNTIF(G3:G100;"POWER")
I divided power by it's count as we get it every month
=AVERAGEIF(G3:G100;"GAS";H3:H100)/COUNTIF(G3:G100;"GAS")/3
I divided gas by 3 as we get it every 3rd month