Power bi tachometer visualizing the last value - powerbi

I send a json with random temperature to Power BI:
[
{
"CPU_Temp" :"12",
"CPU_TempMin" :0,
"CPU_TempMax" :100,
}
]
Then I want to display current CPU data in tachometer (custom Power BI visual)
I use CPU_TempMin for "Start Value", CPU_TempMax for "End Value", CPU_Temp for "Value".
I convert CPU_Temp to a string before sending it to get rid of aggregation on Power BI end (I don't need SUM, AVG etc) but it doesn't have an option for "Don't summarize".
I've checked all the gauges and neither of them has such an option.

Well,
I found the way to "avoid" aggregating functions.
Set all the values that you use(Start Value, End Value, Target Value etc) to AVG (average)
I need to add filter: drag into filters the CPU_Temp field
Than select Top N filter, type '1'
Drag Any Datetime field (you must have it in your JSON) to "By value", select Latest.
Eventually we display Average value calculate from 1 latest value, which is obviously equal to this latest value.

Related

I want to use a calculated field as a constant reference value, but it keep changing with the filter

I have a column Sales and a column date, I want to use the average sales from month 10 (October) as reference to compare with the others months.
I made a calculated field Sales_december like avgIf(Sales,date<parseDate('10/31/2022','MM/dd/yyyy'))
*10/01/2022 is the first date in the date column
I'm using Sales_december as a reference line in a line chart, every time I filter the date to a specific month Sales_december goes to zero. The only solution I found was to create a field Sales_december_const with the average value of Sales_december, Ex.: Sales_december_const =2000
avgOver(ifelse({date} < parseDate('10/31/2022', 'MM/dd/yyyy'), {sales}, NULL), [], PRE_FILTER)
You need to use PRE_FILTER in this position to avoid the filters affecting the value.
PRE_FILTER and PRE_AGG are not supported with avgif, but using ifelse here should work how you have it set up in your calculation.

Conditionally format a table based on average of dataset, but adhering to slicer selections

I have a simple CSV data set such as this.
ID,MainCategory,SubCategory,Type,Value
1,E,E1,Demo,5
2,N,N3,Install,2
3,E,E1,Demo,4
4,E,E2,Install,7
5,D,D1,Install,3
6,S,S2,PM,4
7,N,N2,Install,7
8,N,N2,Demo,1
9,E,E2,Demo,2
10,D,D2,Install,6
11,D,D3,PM,4
12,S,S1,PM,8
13,N,N1,Install,5
14,S,S3,Install,8
15,S,S1,Demo,9
16,E,E3,Demo,5
17,N,N2,Install,3
18,E,E2,PM,6
19,D,D2,PM,6
20,N,N3,Demo,6
21,S,S2,Demo,7
22,E,E3,Install,2
23,S,S1,Install,4
24,S,S2,PM,8
25,D,D1,Install,5
In my Power BI Desktop, I'd like to load this into a table, and conditionally format the Value column based on whether the value in each row is greater than or less than the average for the currently selected data set.
For instance, the average of Value considering the entire table is 5.08, so if there are no filters applied (as in, all my slicers are set to select nothing), I'd like all rows whose Value is 6 or more to be background colored in one color, and the others in another color. For this, I created two measures like so:
AvgOfVal = DIVIDE( SUM(G2G[Value]), COUNTA(G2G[ID]) )
BGColor = IF(SUM(G2G[Value]) > [AvgOfVal], "Light Pink", "Light Blue")
Then I tried to apply the BGColor measure for conditionally formatting the background, but this doesn't work as expected, and instead produces the result below.
I realize that this is due to the fact that the measure is calculated per row, so when conditional formatting is applied, as seen in the AvgOfVal column in the table, it calculates average per row instead of for the entire data set. How can I calculate a measure that takes into account the entire data set (considering slicers), and do the conditional formatting as I need.
Please keep in mind that if a user were to select a slicer filter (say, MainCategory = D), then I want the conditional formatting to reflect this. So in this case, given that AvgOfVal = 4.80 for MainCategory = D entries, I'd like all rows whose Value >= 5 to be in one color, and others in another color.
I realize that this is due to the fact that the measure is calculated per row
Yes. The key is understanding how that happens. When the measure is calculated a "context transition" happens and the current row is added to the filter context.
So what you want is a calculation that removes the row filter that was added in the context transition. So you need ALLSELECTED(), which does precisely that. eg
AvgOvVAl = CALCULATE( AVERAGE('data'[Value]), ALLSELECTED() )
Removing the "innermost" filter which in this case is the filter on the row, but leaving all other filters, ie filters added on the report, page, visual, or filters coming from interactions with other visuals like slicers.

Don't Summarize Option Problem In Power BI

What I Have?
So, I have 4 Columns, First is Date type which will be Axis Value (X- Axis), 3 Decimal Type Value (Values Field) which will represent as Line Chart i.e. 3 Lines inside the chart.
Problem?
When i drag and drop the Decimal Type Value inside the Values Field in Line Chart, it takes as SUM.
I already selected Don't Summarize in Column tools tab with Uncategorised as Data Category.
The problem is when I click the down arrow in the Values Field, it doesn't shows "Don't Summarize" Option.
Now I need my data as it is, no sum no count, nothing.
How Can I achieve that?
There is chance to duplicating the values so you might get more value than the present value. So have to create new table using below DAX then apply to you visual.
DISTINCT(SUMMARIZE(ResellerSales_USD
, DateTime[CalendarYear]
, "Sales Amount (USD)", SUM(ResellerSales_USD[SalesAmount_USD])
)

Obtain MAX of column and display for each row

I'm trying to obtain the MAX of a particular column in a Power BI Report and place this as a new Measure within each ROW of the same dataset. Please see the example below.
Is this possible in DAX and via DirectQuery/LiveConnection? The report is pointing to a tabular model but due to outside factors the measure must be created in the report.
Thanks
You can accomplish this a few ways. Essentially, you need override the filter context so that the MAX function isn't just running over whatever slice you're showing in the visual. Using CALCULATE or the iterator function MAXX, set the wrap the table in the ALL() function to override the context and calculate max over all rows.
= CALCULATE(MAX([Calendar`Year]), ALL('Smithfield_Fiscal_Calendar'))
or
= MAXX(ALL('Smithfield_Fiscal_Calendar'), [Calendar`Year])
To get the breakout by date, you'll need to include a Date table in your model. PowerBI makes this possible with a few different DAX options. As an example, go to your Model tab, click 'New Table' and put in the following expression:
MyCalendar = CALENDAR(DATE(2019,1,1), DATE (2019,1,10))
This is a little trivial -- you'd want to use a useful range of dates but this one matches your example above. Next, add a column to [MyCalendar]
CalendarMonthYear = month([date]) & "-" & year([date])
Go to your budget table and add a similar field
BudgetMonthYear = month([date]) & "-" & year([date])
Go into your Model view and create a relationship between CalendarMonthYear and BudgetMonthYear. This will associate every date in the date table with the particular budget row from your budget table.
Hope it helps.

How can I ouput the values of a column (values() function) as a list in DAX for Power BI?

I use Power BI to create reports and visuals for large enterprise clients.
I have an interesting request from one of my clients: they would like to be able to see a summary of all filters that are applied to a given report. I used the ISFILTERED() function to create a card visual that lists the dimensions that are filtered, but they would like to be able to see which values are being shown. This works just fine when they have sliced or filtered for just one value, but how can I show when more than one is selected? My DAX is below:
Applied Filters =
var myvalues = VALUES(mytable[dimension_column])
return
IF(ISFILTERED(mytable[dimension_column]) = FALSE(),
"Not filtered",
"Column Name:" & UNICHAR(10) & mylist)
When only one value is selected in the slicer, the output is:
Column Name:
Selected Value
Obviously, when more than one value is selected in the slicer, variable mylist will have more than one value and the function fails. My question is, how can I convert the column myvalue to a list in DAX, so I can output each and every value?
What I want to get is:
Column Name:
Selected Value1,
Selected Value2,
etc.
Thank you!
One possibility is to concatenate all the values into a single string.
For example, you'd replace mylist with the string
CONCATENATEX(VALUES(mytable[dimension_column]), mytable[dimension_column], UNICHAR(10))
You're really only returning a single value for the measure, but it looks like a column.
Another approach is, instead of using a card, to simply create a table visual that just has mytable[dimension_column] for the values. This table will automatically filter as you adust slicers.