I am creating a matrix in powerbi to compare current and previous years by month, also to show the % variance, which is the CY-PY/CY.
this is what am getting
what i want to achieve is this
As very limited information is provided:
If the year(2020 and 2021) are columns for each month's values. It would be better to first declare Variance% as a custom column in the edit query(under 'add column' and give the formula of variance).
Select Column 2020,2021 and Variance% ->Right click->Unpivot selected column, this would define all these columns as attributes and store values as Value.
Save and close changes made in the edit query and in the page select Matrix graph and build the graph.
Related
I am working on a table and creating drilldown in power bi matrix. Showing Drilldown From Member to To User. From member will drilldown to User and date. On the column header I see Instead of To User it shows First To User (red arrow). Second After drilling on the same line of From Member there is one of the To User (Blue arrow and yellow highlight) and next to it , it has SUM. Similarly at the bottom at TOTAL there is one To User Name and then SUM. My question is (1) how to remove First from the Fisrt User To. (2) How to remove Yellow Highlited Name . (3) How to remove name from the TOTAL row. Please see image for clarity. Thanks in advance for help.
Ans to question 1 Edit the column name as shown in the image. You can update it to any label you wants and the column header will show the label accordingly.
Ans to question 2 & 3 There is no exact configuration in Matrix for your scenario. In addition, adding Text column in the Values list also do not make that sense as you already facing issue with that column. In Matrix, Values column always considered for Aggregation and for Text type column you can take any of the option from - First/Last/Count. Now with those options, you can not achieve your required output.
Work around (Best for your case): This will solve your issue 1,2 & 3 together in one go. Create a Custom Column to your table as below-
date_user = your_table_name[Date] & " : " & your_table_name[user]
Now, add both your column From Member and date_user to the Matrix's Rows and Sale column to Matrix's Values property. The final output will be something like below (with my test data)-
====================================================
ADD USER DRILL DOWN
Add User(My Case Sub Category) column to Matrix row as below-
The final output will be as below-
To remove subtotals you can turn off the subtotal option at the paint roll while selecting the visual. During my test I was able to remove all totals using only this option.
Hope this solves all your questions. Feel free to add more details and I'll do my best to help.
I have a very basic question in Power Bi I am trying to build a report in which I am using a Matrix Visual to display some data in the below format, However, I want the most recent months data to show first dynamically and then the following months after that, in this case show May first instead of Jan, Apr second instead of Feb and so on and so forth.
You can perform these below steps to achieve your required output-
Step 1:
Add a new custom column "month_name" (if not already available) in Power Query as shown in the picture. Please use the Date column from your source go generate the new column.
Step 2:
Add another custom column "year_month" as shown in the below image. Remember the target is to get the value like - "202001" (YYYYMM) from the date value. You can achieve the same with other conversion option as well. Please use the Date column from your source go generate the new column.
Step 3:
Change type of "year_month" column as Whole Number and get back to your report by clicking on the "Close & Apply" button.
Step 4:
Create a custom column "Rank" in the table as below-
Step 5:
Sort the "month_name" column using newly created column "rank" as shown in the below image-
Step 6:
Finally use the "month_name" column in your Matrix visual's column and this should be come up with your required output.
There is no option to sort matrix headers in power bi.
However there is a trick that you can apply in order to achieve this.
First Create a new column that referes your month column:
DescMonth = Table[Month]
Then create another column that keeps the order of the new column (you will need an ID Month column for this so be sure to create one if you haven't yet):
DescMonthOrder = - ( Table[IdMonth] )
Then sort the DescMonth column using the DescMonthOrder column
Finally use the DescMonth column in your matrix instead of the regular month column.
This way you will be able to achieve the following result:
I've noticed that If you have a table in the Data Viewer in Power BI desktop such as this:
Then, if you insert the same table in a Table Visualization, the table will only display distinct values of the categories:
How can you set up a Table Visualization so that the data is displayed as it is in the Data Viewer where all observations are displayed?
Unfortunately, Power Bi Desktop currently does not have an option to display all observations in the Table Visualization(Oct 2018). I am optimistic the Power Bi team will correct this problem in a future release. If you feel strongly about this feature, please go to the Power Bi improvement Idea post and add your vote.
I'm answering this question to perhaps help others who come here looking for a work around until it gets implemented.
There is currently one work around that I know of: Add an index column to the data table, add this column to your table visualization, then shrink the column width of the index to hide the data. This is not a desirable work around, but might get you a solution in a pinch until the feature is implemented.
So for your example, to add an index column to your table, go to Edit Queries -> Add Column -> Index Column -> From 1
Then - back to your report, add the Index column to the Table Visualization and make sure you select Don't Summarize for the Index Column values tab pull down.
Once the index column is added to your table, and you sort by the index your table visualization should look like the following:
The last step is to hide the index column by shrinking the column width of the index column. Before you do this, you need to turn off word wrap for the columns and the values. Go to the paint roller and in Column Header and Values make sure you turn word wrap off:
then your final table will look like the following with all of the values required. The grey box is my mouse over the shrunk index column and wont show up for you unless you mouse over that area:
I wrote a query in Power BI which returns results like this
Is it possible: For the first column Service Name if value is same in cells than to show value in the first cell and than leaves all the other cells blank until the value is changed, If the new value is repeating than again leave all the cells blank until a new value found
All you need to do is to change the table visualization to matrix visualization.
Just keep the column under the Rows section.
The matrix visualization will then group and hide the repeating values automatically.
For me, when I switched to a Matrix visualization, it displayed all fields in a single column with plus signs to view detail. To show each field in a separate column, go to "Column Headers" and turn off "Stepped layout".
Use Matrix visualization
Add Service Name and Ticket Type into the Rows
Drill down the visule
go to setting, and under Row Header, remove Stepped
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.