I have two tables, one has a column gross profit and the other has total sales and category. I want to divide gross profit by total sales where category = SGA.
How do I get there?
Create measure:
Gross Margin =
CALCULATE (
DIVIDE ( SUM ( Table1[Gross Profit] ), SUM ( Table2[Total Sales] ) ),
Table2[Category] = "SGA"
)
Note: it will only work if you slice it by shared dimensions. If you run into issues, post your data model snapshot - DAX formulas are highly dependent on the model relations.
Related
I have made an measure for showing total sales by each person. I can't figure how to make an measure for dividing total sales by each person BY total sales. For example, for the person "bmo" I want to calculate 303/3153 and so on.
I have tried using the same measure as I use on "Totalt antall salg" and use the Show value as, but that just shows the correct value, and does not calculate it, and I need to use the number for later.
You can ignore filter context by using ALL to get total sales:
VAR _TotalSales =
CALCULATE (
COUNTROWS ( 'KasseJournal' ),
FILTER ( ALL ( 'KasseJournal' ),
'KasseJournal'[Hendelse] = "Bekreftet kasseekspedisjon"
)
)
RETURN DIVIDE ( [Totalt antall salg], _TotalSales, 0 )
I have a measure that is comprised of other measures. I will post below pictures. I am calculating the forecast for the month per location. I created a measure for that and the total is correct for that. I created another measure that calculates the working days in a month and when I divide by this measure, I get the correct results per the location but the total is wrong.
This measure shows the measure I am using to calculate the total forecast for the month per location.
"MPP = (CALCULATE(SUM('TF'[ Forecast ]), DATESBETWEEN ('TF'[Date],[Month Start-pp], [Month end_pp] )))"
This measure shows the measure I am using to calculate the working days in a month.
"Days per location =
CALCULATE (
COUNTROWS ( 'TF' ),
FILTER (
'TF',
'TF'[Date].[MonthNo] = MONTH ( TODAY () )
)
)"
The pic is showing the totaling. The first column is the measure without the division and is correct totaling. The second column is where the issue is.
I would like to calculate Percentage value of total (same as inbuilt "show as -> percentage of grand total" but using DAX).
I have seen solutions
Percent of Total Windowed in Power BI DAX
and
Power BI DAX - Percent of Total Column with FILTERs
and
How to calculate Percentage out of Total value in DAX (Power BI Desktop)
but unfortunately all of them do not work for me (I get all rows filled with 100% for calculated column)
Idea is to have percetage of total but be able to apply date filter and see percent value of shown data, not entiry query
I tried as in above mentioned solutions:
Percentage =
DIVIDE(
SUM( All_Years[Price:] ),
CALCULATE(
SUM( All_Years[Price:] ),
ALLSELECTED( All_Years )
)
)
First of all I do not understand why do they take SUM in numerator. If I use just
Percentage =
DIVIDE(
All_Years[Price:],
CALCULATE(
SUM( All_Years[Price:] ),
ALLSELECTED( All_Years )
)
)
then situation looks better, I get percent value of total table in each row. But then when I apply date filter in Visual I see total 3.5% (which is correct if we consider full query and not slice that I got after applying filter)
Leaving ALLSELECTED blank also does not resolve the problem.
what am I missing?
I am working in Power BI and I created a DAX measure that adds up two other DAX measures.
For one measure I need it to ignore the month slicer because I need the total for that category. Is it possible to do so?
Also, is it possible for it to ignore the slicer and still give me the total for unfiltered DAX measure + the date filter DAX measure?
DAX code:
Monthly Total Act =
CALCULATE (
SUM ( 'sheet1'[Amount] ),
FILTER ( 'sheet1', 'sheet1'[Type] = "ACT" ),
FILTER ( 'sheet1', 'sheet1'[Bill] = "Y" )`
)
Monthly Total of Acs =
CALCULATE (
SUM ( 'sheet1'[Amount] ),
FILTER ( 'sheet1', 'sheet1'[Type] = "ACR" ),
FILTER ( 'sheet1', 'sheet1'[Bill] = "Y" )`
)
Adding these two formulas together to get the total monthly.
The monthly total of ACS is where I encounter the problem. I need this to be unaffected by the slicer
The end goal is having the month total of ACS unaffected by the data slicer and add to the monthly total of Act that requires filter by the current month.
Yes, you can add this line as a third filter argument in the calculat function you want to ignore the month slicer:
ALL('tableName'[monthColumnUsedAsSlicer])
Then the monthe slicer will not affect calculations.
I am new in Power bi. I have a table where I have agents details. I have their scores as well. I have date wise data into table where the following columns are available -
I have created created measure for Average of Score where Metric is UES AGGREGATE -
I have to get the ranking of the advocate(s) for the Average Score (UES AGG). I have tried this measure for Ranking calculation -
Rank_UES = RANKX('RankSummary',[RKS_UESAGG])
I am getting wrong ranking. Please help me , how to solve the issue.
Thanking You.
Use ALL function with RANKX.
Rank_UES =
RANKX (
ALL ( 'RankSummary'[AgentfullName] ),
[RKS_UESAGG]
)
I do not know if your [RKS_UESAGG] get you what you want. Suppose you want average sales you make something like this:
Rank_UES =
RANKX (
ALL ( 'RankSummary'[AgentfullName] ),
AVERAGE ( 'RankSummary'[Amount] )
)
https://learn.microsoft.com/en-us/dax/rankx-function-dax