Power BI chart to highlight and compare any three periods of data - powerbi

Does Power BI have a chart that can highlight to compare three periods? In this case, they are current month, previous month, and the same period last year.
I have the three measures ready but couldn't find a chart type to highlight the periods I want to compare and grey out the rest.

I believe the key here is using a measure on the chart's color saturation field.
I was able to achieve the following where the bar colors are dependent on the date slicer:
I defined my measure like this:
Color =
VAR SelectedDate = SELECTEDVALUE(Cal[Month])
RETURN 0.5*(EOMONTH(SelectedDate, -12) IN VALUES(MTS[Date])) +
0.8*(EOMONTH(SelectedDate, -3 ) IN VALUES(MTS[Date])) +
1*(EOMONTH(SelectedDate, 0 ) IN VALUES(MTS[Date]))
where MTS is a monthly time series table and Cal is an unrelated calendar table that only has month ends. Only one of the conditions holds at a time and the constants in front just define where on the color range the result will land when the condition returns TRUE() (which gets coerced to be 1 when multiplying).
Once you've put a measure on the color saturation field, you can access the data color settings under the Format section:

If you are just looking to highlight three measures manually to distinguish from the others you can go into the Format tab, and under "Data colors" you can toggle on the "Show all" option and change them there.
You could also use a slicer.

Related

DAX to calculate max of all visible monthly totals for all series in a chart

I have a "Line and clustered column chart" in Power BI where the bars are actual values and line is budgeted values. Actual and budgeted values often vary enough that their Y axis scaling doesn't match, so I need both axes to have the same scale. Start value for both could be zero, but End needs to be calculated. We need to dynamically calculate End based on the visible data within the chart. My approach so far has been to create a measure that calculates the highest monthly actual value and another measure that calculates the highest monthly budget value, then take that max of those two measures and use it in a function for the "End" value of both Y axes. I have not found the DAX that works yet.
Example of y axes with different scaling and the max value we want
I suspect I'll need to get the min and max dates that are selected in the visual, and the following measures give me those:
MinSelectedDate = CALCULATE(MIN('Date'[CalendarDate]), ALLSELECTED('Date'))
MaxSelectedDate = CALCULATE(MAX('Date'[CalendarDate]), ALLSELECTED('Date'))
I also suspect I'll need to build a table within the measure and summarize the values then iterate over that table to find the max. Somthing like this:
MaxActual = MAXX(
SUMMARIZE(ALLSELECTED('FactActualValues'), 'Date'[FirstDayOfMonth], "Volume", [Actual Values]),
[Actual Volumes]
)
However, when I try this DAX the data ends up being sliced by the month within each year. I'm using a matrix for dev/test.
Dev/test using matrix
The optimal solution is to have an analytical model with two columns (Date and FY).
Cancel dynamization of the table, setting the years to the "Year" column and converting it to Text type
Create the column "Month" from the month number of "MonthName" and convert to type Text
Create the date column of the format dd-mm-yyyyy from the concatenation using "01/"+[Month]+"/"+[Year]
Format the new date column to date format
The y-axis scale is resolved by the "Clustered Column Chart" visualization as it takes the maximum value of a single column of values plus some margin at the top and takes that as the y-axis value.
Got it! I was very close but didn't need to calculate min or max dates. Using ALLSELECTED gave me just the records from the FactActualValues table that I needed without applying an explicit filter. I also learned that some functions (e.g. - MAX) cannot "see" columns returned by table functions, but others like MAXX do support it. SUMMARIZE allows you to create a column and I learned that some people use the empty single quote to reference such a column.
Here's the DAX that works:
MaxMonthlyActual =
MAXX(
SUMMARIZE(
ALLSELECTED('FactActualValues'),
'Date'[FirstDayOfMonth],
"#ActVol", SUM('FactActualValues'[Total])
),
''[#ActVol]
)
Here is what the chart looks like using the DAX measure:
Chart with Y axes with matching scales

User Input Date in DAX column in POWER BI

I am trying to create a column in Power BI to group the rows of that data on.
I want the column to output text based on a comparison of dates.
Example:
projected = if(staticdate1 > dynamicdate, "XX", if(staticdate1 < dynamicdate && staticdate2 > dynamicdate, "YY", .... )
The dynamicdate presumably would be a filter or slicer the user could click a date on, thus changing the output of the column, and the totals per output would also change.
Is this possible? I've tried SELECTEDVALUE() but that didn't work. I tried creating a "what-if" parameter and adding that to a static date, but that didn't change anything when I changed the parameter.
That’s not possible since calculated columns are static and don’t recalculate on filter changes. This works with measures only.

In PowerBI what options are there to hide/redact/mask values in visuals to anonymise data

What options are there in PowerBI to suppress, redact or hide values to anonymise values in reports and visuals without loosing detail and have that restriction apply to multiple pages in a report?
Cat
Count
%
Category 1
23
10
Category 2
2
0.9%
Category 3
4
1.7%
So that its possible to keep the rows but end up with a placeholder where count is <4 and % is greater than 1% but less than 2%
Cat
Count
%
Category 1
23
10
Category 2
*
0.9%
Category 3
4
*
So far my experience has been
a measure with a filter applied will hide rows but you can't apply a measure filter to an entire page or all report pages.
Ive seen mention of conditional formatting to hide the value by having the font and background the same colour but that seems open to error and labour intensive.
I also want to be clear when a value has been suppressed or masked
I suspect there is a more better way but I haven't been able to figure out where to even start.
OK, I have something working but you will need Tabular Editor to create a calculation group. Here are the steps.
I'm using the following table (named "Table") as the source data.
Add two measures (calculation groups only work on measures) as follows.
% Measure = SUM('Table'[%])
Count Measure = SUM('Table'[Count ])
Open tabular editor and create a new calculation group named "CG" with a calculation item named "Mask". Paste the following code into the calculation item.
if (
(selectedmeasurename() = "% Measure" && selectedmeasure() >1 && selectedmeasure() <2)
||
(selectedmeasurename() = "Count Measure" && selectedmeasure() <4)
,"*",selectedmeasure()
)
4. Save the calculation group and in Power BI drag the name column onto the filter for all pages as follows, ensuring it is selected:
The masking will now happen across all reports automatically. Below you can see the same table on two different reports which have now been successfully masked.
It depends on your data connection type as to whether this is available, but a calculated column (instead of a measure) can be used as a filter at the "this page" or "all pages" level.
If this option is available, then you can find it right next to the "New Measure" field.
Using this and your sample data above, I created a couple of calculated columns and show the resulting table. You can then display these columns and use them as filters throughout the report. Your DAX may be slightly different depending on how the actual data is formatted and such.
Count Calculated Column
Masked Count =
IF(
'Table'[Count] < 4,
"*",
CONVERT('Table'[Count], STRING)
)
% Calculated Column
Masked % =
IF(
'Table'[%] > .01 && 'Table'[%] < .02,
"*",
CONVERT('Table'[%] * 100, STRING) & "%"
)
Resulting Table
Example of how the filter can be used
The values of these columns will update as your data source is refreshed in Power BI. However, calculated columns aren't available for Live Connection, in which case you would have to do this kind of logic at a lower level (in Analysis Services for example).
Additionally, you could potentially use Power Query Editor to accomplish this kind of thing.

PowerBI - conditional formatting for highlighting weekends

I have a data table matrix in power bi showing Dates in Rows and hours in columns and count of customers against them as values. i wanted to highlight all rows of thursday, friday and saturday, so that weekend figures can be compared.
Need help in this pls...
the table is in the below format
enter image description here
First you want to create a duplicate (in my case monday - friday (2) that does NOT have a relation to you source table. You want this duplicate table to only show days. This duplicate table needs a relationship with the slicer you are going to use to filter for days
In your source table (monday - friday) you want to create the following measure:
Measure = IF(HASONEVALUE('monday -friday (2)'[Day]);
IF(SELECTEDVALUE('monday -friday (2)'[Day]) = MAX('monday -friday'[Day]); 1; 0);
IF(ISFILTERED('monday -friday (2)'[Day]) && COUNTROWS(FILTER('monday -friday (2)'; 'monday -friday (2)'[Day] = MAX('monday -friday'[Day]))); 1; 0))
Now you want to create conditional formatting. First create your table with days and values (for the example i did not sort the table. You want to sort your table so it looks better):
Then right click on values and select conditional formatting. Select based on rules.
and the measure you just created in your source table.
for the first option you select "is bigger than or equal to" and give it a value 1.
for the second option you select "is smaller than"and give it a value 1000.
Choose the color you want your highlights to be.
If you now select a day in your filter the value for that day will show the background color you selected! In your case you want to select all days you want to have highlighted.
Hope this helps!

How to pick up column by given parameters and then sum-up the column total in Power BI

I've got a table like below. I would like to pickup the column first by given parameters then sum up the total of the column.
For example, by given Parameter of SGD, I would like to sum-up the total amount of column SGD.
Date SO NO. AUD SGD HKD
7/1/2019 SO1 100 105.17 545.74
8/5/2019 SO2 130 122.01 691.13
9/9/2019 SO3 160 150.32 853.55
9/15/2019 SO4 180 169.11 960.25
Thanks
One way to achieve this is to add a new disconnected table Currencies with one column Currency and values AUD, SGD and HKD. Add a slicer for it and make it drop down.
Then create a measure, which will take the value of the slicer and calculate total on the corresponding column, depending on the selection in the slider:
Total = SWITCH(SELECTEDVALUE('Currencies'[Currency]; "AUD");
"AUD"; SUMX('Table'; [AUD]);
"SGD"; SUMX('Table'; [SGD]);
"HKD"; SUMX('Table'; [HKD]);
SUMX('Table'; [AUD]))
SELECTEDVALUE('Currencies'[Currency]; "AUD") will return the value selected in the slicer, or AUD if none or multiple values are selected. See SELECTEDVALUE.
SWITCH will compare this value with a list of possible options (AUD, SGD and HKD) and return corresponding expression (SUMX('Table'; [AUD]), SUMX('Table'; [SGD]) or SUMX('Table'; [HKD])), or some default value if there is no match (SUMX('Table'; [AUD])).
Then use this measure in your report, and it's value will change depending on the selection in the slicer: