I have a chart as below,
Here I have certain metrics which needs to be shown as Monthly, quarterly, yearly.
Ex. if monthly is selcted chart should show in months as mentioned,
if quarterly is selected chart should show in quarter and same applies for yearly.
So I tried with following code,
Created a table,
|Monthly|1|
|Quarterly|2|
|Yearly|3|
Created the selcted value measure as
select = selectedvalue('table1'[column2])
Created a switch to use that calculated column in axis of the bar chart,
switch[select]
1,'calendar[Month]',
2,'calendar[Quarter]',
3,'calendar[year]')
Output is showing as variant data-type cannot be used in calcualted column,
I understand that some values are either text or number, how to change accordingly to same datatype.
I have tried with zero also it is showing the same error.
Is there any other approach to this dynamic changing of columns?
You can add buttons and use bookmarks to assign action based on Month, Quarter and Year to those buttons, all you need to do is create 3 visuals and align them then based on buttons make the visual visible/invisible and the update the bookmark.
Related
I have got a column chart with 79 geographies and a slicer with the 79 geographies. The column chart is NOT dependent on the slicer however there are other visualisations in the page that are dependent on the slicer.
What I would to achieve is when I select a specific geography in the slicer the bar that corresponds to that selected geography should be highlighted (i.e. a different colour fill). Can someone please let me know if it is possible to achieve.
I was able to achieve this partly by creating an independent slicer. Not coming from the table or joined to the table. I created 2 new measures, one that shows the selected value in the slicer and the second measure to give it a colour. I used this to change the data colour by using "fx" to determine the colour of the column. I am attaching the Power BI file that shows this solution for your reference.
But by doing an independent slicer my other visualisations don't update. I am wondering if it is possible to achieve this without creating an independent slicer so that my other visualisations are not affected.
Any help is greatly appreciated. Thank you.
Measure 1: Measure = SELECTEDVALUE(Locality[Locality])
Measure 2: Colour = IF(MAX(Sheet1[Locality]) = selectedvalue(Locality[Locality]),"red","blue")
Please see below the screenshot and also link to the sample .pbix file for your reference.
Sample Power BI file - https://1drv.ms/u/s!AubIV2PXG9p4gqhykbbmeMfFYlChCw?e=w6UABf
Disconnected table solution file - https://1drv.ms/u/s!AubIV2PXG9p4gql1_KvyEK82cZZDMw?e=7TAR6i
You did a great trick as I checked your solution file. But slicer not working as expected which is your issue as per your explanation. To make it work, you can just think reverse of what you have done now.
You have separated slicer value from other data, so that selecting a value in the slicer still keep all Locality in the Bar chart. But problem is, its also keeping all localities in other charts where you wants to take effect of slicer selection. Right?
If the above explanation and assumption is correct, just separate your Locality and Population column to a different island (no relation) table. And create your BAR chart from the new table. Now, if you select a value in the slicer, all charts will be filtered accordingly but the BAR chart.
Finally, apply the Color measure to FX as you implemented currently. This will work as I tried it here and got success. Following is the sample output-
I am attempting to create a cumulative graph much like this one:
I have the following table in PowerBI
BugHistory
BugID
Date (date)
DateTo (date)
EntityStateName (text)
Effort (number)
I would like to do a measure that would tell me the amount of summed Effort on any given date for each EntityState.
I have tried quite a few things, even adding a Date Table using the Calendar, but getting the values to be shown correctly on a StackedGraph seems to be beyond me.
Hope someone can help.
Follow the following steps:
Right click on the column "Effort" and click the option called "New quick measure" in the right click menu.
In the window that appears, choose "Running Total" under the Calculation drop-down
This will show 3 new fields
In the Base Value field, drag and drop the "Effort" column
In the Field column drag and drop the "Date" column.
In the direction column choose Ascending
This will create a new measure in your Table. You can use that measure in you chart.
You can refer to the following video for reference: https://youtu.be/KlXclbN4oWE?t=497
My data source is a list of events. There is one column with a timestamp, and other columns are attributes (type, location, severity, etc) of that event. I would like to produce a "weekly report".
Most of the charts on this report will be based on the events that occurred in the user-selected week. Example: column chart showing count of events per location. Other charts are to show the current week's counts compared to previous weeks. Example: line chart showing the total count of events in each of the last 12 weeks
I believe I can achieve this by having two separate slicers, one for selecting the dates of the current week, the other to select the comparison range, and each chart linked to the appropriate slicer. Ideally, however, the user would be able to select a single range (e.g. the week of the report) and the second set of charts would be relative to it. Is this possible?
I produced the following example using 2 slicers, both referencing the Date field, but one slicer for each chart. I want both charts controlled by a single slicer:
I have Slicer InsurType, Pie Chart Premium by Division and Card that represents Budget
On a picture below all InsurType are selected and Budget shows correct amount (101.4M).
If I choose parameter on a slicer, then the Budget value also represents correct amount (picture 2).
But now, if I click and choose value on a pie chart - then the Budget value will not be effected.
I tried to change Edit Interaction but still - no effect.
So why the Budget value is not filtered by Pie Chart selection?
I am assuming its something to do with relationship that have "BudgetDate" table and "Divisions"
Divisions table looks like this:
Any advise how should I fix this issue?
It looks like there is no way for the Premiums table to affect the BudgetData table based on your diagram (look at the way the arrows are pointing).
I'd suggest editing the relationship to allow two directional filtering by changing the "Cross filter direction" from "Single" to "Both".
MWE set up:
1) From the Power Bi visual website: https://app.powerbi.com/visuals/ there is a custom download "Box and Whisker (Jan Pieter)"
2) Download sample.
3) create new measure with dax formula:
Distinct count score = if(distinctCOUNT(Courses[Score]) > 4, average(Courses[Score]), Blank())
4) Add a Stacked column chart with Course as the axis and the newly created 'Distinct count score' as the Value and get the following:
5) compare this graph to the Box and Whisker provided by Power BI:
Here is my problem. I only want to show values in the Box and Whisker where the Distinct Count of Scores is greater than 4 -- So I only want Physics to show up (like the stacked column chart above).
So if I try the solution working with the stacked bar chart using the Dax formula. I get the following--nothing shows up:
And this is what I want to happen:
Question:
Is there a way in Power BI run and distinct count statement within a Box and Whisker chart to only show data with > 4 distinct values (or any if statement)?
I want it to be formula based, I cannot just 'visual filter' items I do not want.
Possible answer:
I thought about going to the source code to try and 'throw in' a if statement. But I went to the developers git hub: https://github.com/liprec -- I couldn't find the repo for this visual.
Basically this is due to the way the box and whisker chart is working. The visuals needs a dataset to calculate the values (mean, median, etc.) and use those values to show the box and whisker.
So in your case you need to create a measure that is on the same level as the scores (because those values are needed) and is only available. See the screenshot for a visual explanation of the needed measure.
I created the measure with the follow DAX measure:
Filter Score = IF(CALCULATE(DISTINCTCOUNT(Courses[Score]), ALLEXCEPT(Courses, Courses[Course]))>4, MIN(Courses[Score]), BLANK())
The Boolean expression of the IF statement calculates the distinct scores per course via a CALCULATE expression and the ALLEXCEPT filter option to ignore everything but the course value. And the TRUE part returns the score which needs to be aggregated, so the MIN and the FALSE part return a BLANK() value so is can be ignored.
When you add the new measure and create a BW chart it will only show 'Physics' course results.
If you need more help, please let me know here or via email.
-JP
BTW: I just updated my PowerBI visual GitHub repository (https://github.com/liprec/PowerBI-custom-visuals) and added my box and whisker chart and my hierarchy slicer to it in the folder oldAPI.
The crux of your problem, as far as I can tell, is that you want to filter visuals to courses that have a particular number of distinct values. Which visual you want to use is almost irrelevant (though it was helpful to have a sample Power BI workbook to follow along with).
The way I'd approach this (and not saying this is the best or only way)
Step 1
Create a new Course dimension table, with one row for each unique course. In the sample workbook, you can click 'Enter Data' and manually type in the data.
Course
------
English
Math
Physics
Step 2
Next, create a calculated column in the new table and calculate the distinct count for each course. This isn't a measure - it's a column in your table, that uses the Distinct Count calculation from your question.
Distinct Count = CALCULATE(DISTINCTCOUNT(Courses[Score]), SUMMARIZE('Courses','Courses'[Course]))
The SUMMARIZE works like a GROUP BY. In essence, creating one row per course with a distinct count of scores.
Step 3
Use this new attribute as a filter on your visual. You can then dynamically alter the number of distinct values as you feel like (4, 3, 2).
I know this isn't quite as good as typing a formula into the visual filter field, though in practice it's still formula driven. The formula is just on an underlying table.
Why so complex?
The reason you have to do this for the Box & Whiskers visual, whereas your 'Distinct Count score' measure works so well, is that on the column chart, you are displaying a single value (the average score). The Box & Whiskers chart, by contrast, is plotting every individual score.
In fact, if you removed the 'Course' from the axis of your column chart, the value changes as it adds back in the courses you filtered out. (The reason for this is that, if no course is on your axis, your formula calculates the distinct count of all the courses, which is 7). Likewise, if you were to filter your column chart to a particular session, your column chart would go blank (since in any given session, no course has more than 4 distinct values).
The technique I've described above fixes those problems, because it filters out the courses Math & English from the get-go. It doesn't matter if you've filtered to a single session, or not filtered by course at all. English & Math will always be excluded as long as their distinct count is below the value you specify.
Hope this helps.