I have a table of number of visual:
visual_1000x123
0
1
I would like to use a dropdown list to let people select 0 or 1.
If 1 is selected, the calculate result will be xxx(let's say 55k).
If 0 is selected, the calculate will be 0.
Maybe I should mention that there is a time filter, which works well.
The result varies according to the selected period.
This measure keeps giving me 0:
measure = IF(MAX('Simulateur'[visual_1000x123])=0, 0,
CALCULATE(SUM('Prévision Leaderboard'[Budget_impressions/1000x123_et_1000x167])) +
CALCULATE(SUM('Prévision Middleboard'[Budget_impressions/1000x123_et_1000x167])))
This measure keeps return 55k:
measure = IF(MAX('Simulateur'[visual_1000x123])=1, 0,
CALCULATE(SUM('Prévision Leaderboard'[Budget_impressions/1000x123_et_1000x167]))+CALCULATE(SUM('Prévision Middleboard'[Budget_impressions/1000x123_et_1000x167])))
I also tried to multiply the number of visual, but it didn't return anything:
measure =
(CALCULATE(SUM('Prévision Leaderboard'[Budget_impressions/1000x123_et_1000x167])) +
CALCULATE(SUM('Prévision Middleboard'[Budget_impressions/1000x123_et_1000x167])))*MAX('Simulateur'[1000x123])
If I am understanding your question correctly, you just want to multiply a number in a column by a factor (which is in a slicer, or visual).
If that is the case you can do it simply as follows:
column1 * factor result = AVERAGE('Table'[Column1]) * AVERAGE('Table (2)'[factor])
Posting this answer myself.
It's due to my data structure. All the data was in one table and I should have them seperated into different tables.
Related
Looked around a long time now, and cannot find a way to conditionally format the values in a table, treemap, bar chart etc. if they are within the say, top 80% of all the values.
So let's say I have a table with sales and profit. Then I have a treemap showing the profit by city. I manage to get the percentage of total with:
% of total profit = SUM(Orders[Profit])/CALCULATE(SUM(Orders[Profit]),ALL(Orders))
..so that is no issue. But how would I go about formatting the cities that are within the top 80% of all profit? Any suggestion on approach?
Example:
Say I have the treemap below. The first four categories would fall within the top 80% of the total. Cumulatively it would be: 35%, 55%, 70% and 85%. So my need is to color only these in a specific way (and preferably any that falls outside of that range, in another color).
I take it that finding the logic to do this, likely though a measure somehow to base the formatting on, will then also be something that would be applicable to bar charts etc. (more traditional pareto).
OK, here is the solution. I will provide a traditional pareto and an adapted one according to your requirements. My data looks like this.
Create 3 measure as follows:
1
Profit Measure = SUM('Table'[Profit])
2
Pareto =
VAR amount = [Profit Measure]
VAR total = CALCULATE( [Profit Measure], REMOVEFILTERS('Table'))
VAR result = CALCULATE([Profit Measure], FILTER(ALL('Table'),[Profit Measure]>= amount))/total
RETURN result
3
Threshold =
VAR pareto = [Pareto]
VAR previousPareto = MAXX( FILTER( SUMMARIZE(ALL('Table'),'Table'[Order],'Table'[Profit],"p", [Pareto]), [p] < pareto), [Pareto])
RETURN IF( ISBLANK( previousPareto), pareto, previousPareto)
Create a table visual so you can see what is happening. In the table below, the Pareto measure is creating a cumulative percentage based on profit. If you were to use this, you can see that only A and B are cumulatively the only values actually < 80% and so they would be the only ones coloured. What you are asking for is slightly different which is what the threshold measure is showing. This outputs the previous pareto (or current if there is no previous).
In the tree map, I have created the conditional formatting as follows for standard pareto.
And as follows for the adapted pareto.
Click the fx icon under colors.
Select Rules for Format style, your measure as the field and then set up a rule (in your case, >= 0.2 for top 80%).
I’m wondering if there is a way, in a table, to calculate the percentage over a grand total.
I think this is a fairly simple issue, but I really can't wrap my head around it.
I have a table with a count, divided into different Categories:
I also have several slicers:
What I would like the table to show is the percentage of the current selection over the grand total, while keeping at least other two filters set (the Year(Anno) and another one set on the entire page).
If I select in the slicer “Range Scostamento %” a value, the table will obviously update the numbers:
The value I’m looking for is the “weight” in percentage of the filtered values over the total value.
So for example, for the first row I will have 317/14.793 = 0,0214 = 2,14% and so on.
I think my question has something to do with the SELECTEDVALUE/ALLSELECTED, maybe KEEPFILTERS, but I really don’t know how to make it work.
Thanks in advance!
Alessia
If I understand your requirement correct, you need these below measures for your purpose-
contratti = count(table_name[column_name])
grand_total =
CALCULATE(
count(table_name[column_name]),
ALL(table_name)
//-- ALL will return count of entire table
//-- you can use ALLSELECTED if you wants the
//-- grand_total for filtered data based on slicer
)
percentage = [contratti] / [grand_total]
The Films table looks like this
There is a ComfortBreaks table looking like image
In the Films table I need to create a calculated column called NumberBreaks which shows for each film the number of breaks needed. To do this I have to pick out the value of the Breaks column where:
The value of the lower limit in the ComfortBreaks table is less than or equal to this film's running time in minutes
and
The value of the upper limit in the ComfortBreaks table is greater than this film's running time in minutes.
the result should look like the image below
There cannot be a relationship between the two tables. so this has to be done without creating relationship between them.
I tried lookup function but it showed error:A table of multiple values was supplied where a single value was expected.
You can use this below code for your custom column. Considering
number_of_breaks =
VAR current_row_run_time_minutes = Films[RunTimeMinutes]
RETURN
MINX (
FILTER(
ComfortBreaks,
ComfortBreaks[LowerLimit] <= current_row_run_time_minutes
&& ComfortBreaks[UperLimit] > MonthNumber
),
ComfortBreaks[Breaks]
)
You can perform your further average calculation on the new custom column now.
I need to develop a report with a table that includes several dimensions and displays a sales revenue measure. Most of the times this measure throws a zero, but the user wants to visualize a blank space instead. I have searched around, but I couldn´t find anything that gives me support. So if anyone has experimented this or found a workaround I would thank you for your time.
You could use a IF condition to replace 0 with blanks. For example, if you are summarizing a field called "Sales" the following formula would work:
Measure = IF(Sum(Sales)=0,"",Sum(Sales))
Hope this helps.
Adding the additional option based on Ricardo's suggestion:
Measure = IF(Sum(Sales)=0,Blank(),Sum(Sales))
If you have a measure [Measure] and you want to replace 0 with a blank, you can do the following:
MeasureReplaceBlank =
VAR Measure = [Measure]
RETURN IF ( Measure = 0, BLANK(), Measure )
Note that since I stored the calculation of [Measure] as a variable, I don't need to call it twice (once for the condition and once for the True branch of the IF function).
it seems like PowerBI is auto-ordering my table and I don't know why. So, I have this table (that I exported from a Excel file)
Colonne 1
7
25
1
8
3
Whenever I do a New Mesure, with this formula:
Mesure = FIRSTNONBLANK(Feuil1[Colonne 1];0)
It gives me the number 1. If I do LASTNONBLANK, it returns me the number 25. So it clearly auto-order my dataset, but whenever I look in the «Data» tab of the software, I see that my data are ordered the way I want them to be.
Any idea on how to keep the default ordering?
Unfortunately, that's the exact behavior of FIRSTNONBLANK() and LASTNONBLANK(). They iterate the values of a column based on their native sort order (i.e. data type). Therefore, FIRSTNONBLANK would return the smallest number 1 and and LASTNONBLANK the largest number 25. And in general, you cannot make assumptions on sort order of values in a table or in a column when using DAX.
Therefore, my suggestion is that you can explicitly program the logic to find the target value. Say the table is sorted based on date, you can find the key of the earliest/latest date (based on your use case), then lookup the value using the key.
Target =
VAR TargetKey =
CALCULATE(
VALUES(Table1[Key]),
FILTER(
Table1,
Table1[Date] = MIN(Table1[Date]) // or MAX(Table1[Date])
)
)
RETURN
LOOKUPVALUE(Table1[Colonne 1], Table1[Key], TargetKey)