Power BI clustered column chart as percent by group - powerbi

I have table with student responses in power BI. A row consists of semester, Course, Program, Department, Instructor and student response (Always, Frequently e.tc)
I would like to create a stacked (not 100%) column chart based on percentages.
for example: For each semester code (124,145) when a user makes a selection on any of the slicers, I should get the proportion of each response as % of semester Total.
I created a
Measure= DIVIDE(CALCULATE (countrows (fact_table[response])),
CALCULATE (countrows (fact_table[response]),ALLEXcept(semester, course, program, department, instructor)).
It produces wrong results when some slicers are not selected.
My slicer are semester, course, program, department, and instructor
I would highly appreciate some help

Related

Using a slicer to filter a line chart in such a way that it shows a separate line for each measure and different formatting

Here is what my client wants:
A line chart filtered by a slicer. When they click on a category, they want to see a line for each distinct instance. Let's say the X-axis is the week, Y-axis is a measure called [Sales%]. This measure is a percent.
If they click on category "Country", they want a separate line for each country that appear in the dataset. If they click on "City", they want to see a separate line for each city instance.
To solve this I used field parameter, where I use the columns in the dimension tables to give me the lines for a category. It works very well.
But the last choice on the slicer is called "Sales Indicators". And let's say the company has 6 sales indicators (average for 4 weeks back sum of boolean values from the fact table - decimal values). For each sales indicator there is a separate measure.
The fact table granularity is daily, while the report is on a weekly basis.
Now when they click on "Sales Indicators" they want to see a line for each measure. This is not a category, but a group of measures and I don't know (if it's possible) how to use it in the parameter. How to make the slicer filter for these 6 measures.
And then there is the problem with the data type. Only this 6 measures (the last option of the slicer) are decimals. All other options show [Sales%] by category. How can I approach the problem?

Power BI: How to Create a Matrix with Row Headers = Data label, Column Headers = Measures

I have a dataset consist of two time series: e.g. Historical stock prices for Apple and Microsoft. And I have a few different power BI measures created for each of these two stocks (e.g. Weekly Return, Monthly Return).
I want to create a "Matrix"-like visual, to show:
stock names as the row headers
measures as the column headers
values being the corresponding measure value for the given date selected on a date slicer
To illustrate what I want to do, please see the picture from Excel as an example. Is there a convenient way to do this in Power BI?
Thank you very much for your help!
Excel illustration on what the visual should look like in Power BI

In Power BI, how can I create a column that changes based on a slicer and visualization?

I'm pretty new to Power BI. I'm unsure how to approach this.
I have one visualization that displays the ten most frequently bought products in a time frame that is set by a slicer. In another visualization, I display how those products have been selling over the past few years (this time frame is not determined by the slicer). I want to display only the ten products that come from the first visualization, not the ten most common over the time frame in the second visualization.
How can I accomplish this? The approach I have in mind (and I'm open to others) is to create a true/false column that changes with the first visualization. "True" would be for products that are frequently bought as determined by the first visualization in the slicer-determined time range, and the second visualization would only look at values with a "true" in that column. How can I create a column (or table, maybe?) that changes depending on a visualization?
Clarification: most of the pages will say Top10 ... Actually, the measure used was a simple Top5 that includes products with the same number of orders than the 5th product. Therefore, to avoid dealing with larger images, 7 products will be seen but it is a Top5 ranking. The idea is you can replace it with your custom TopN measure.
What I understood:
The simplification of your model plus the disconnected help table would be:
I have one visualization that displays the ten most frequently bought
products in a time frame that is set by a slicer.
The Date slicer belongs to the Dates table in the Data model.
The table viz represents the number of rows in the sales table in the
current context (for each product within the Date range).
The table viz is sorted according to the [#Rows] measure in descending
order.
The table viz only presents the TopN products even without the presence
of the [#Rows] measure due to the presence of the [TopOrders]
measure within Filters on this visual. [TopOrders] is 1.
On the second page you create:
A slicer with the Dates[Date] column (the same one used on the
previous page).
A matrix with Products[ProductName] on the rows, HDates[Year] on
the columns, and a measure on values.
From the View tab, you select the Sync Slicers option.
Inside the Sync Slicers pane:
In the Sync column, check the boxes related to the necessary pages.
In the Display column uncheck the box that contains the over
years report.
So far all we have done is pass the time frame context from page 1 to page 2.
Since the TopN context depends on the time frame context, we can now use the [TopOrders] measure as a Filters on this visual in the matrix. Again, [TopOrders] is 1.
Why do the numbers differ between rows and not between columns?
Also, in this example, the Sales table only has information up to 12/31/2020 but the visualization shows an additional year and the Sales[Amount] values for each order is $1 so that [#Orders] and [SalesAmount] are the same for easy comparison.
HDates is not related to the model and for each combination of HDates[Year]-Products[ProductName], the [SalesAmount] measure is using the information coming from the previously hidden slicer and the respective Products[ProductName] because the information coming from HDates[Year] has no effect yet.
In order to complete this exercise, it only remains to modify the [SalesAmount] measure in such a way that it removes the filter on the time frame (Dates[Date]) and it recognizes HDates[Year] as Dates[Year].
SalesAmount :=
CALCULATE(
SUM(Sales[Amount]),
ALL(Dates),
TREATAS(VALUES(HDates[Year]),Dates[Year])
)
And this is the final result.
I hope it works for someone or the idea can be improved.

PowerBI measure calculates average incorrectly - why?

To preface this, I'm fairly experienced in Excel and VBA but new to PowerBI and more than a bit confused.
I have a flat table with a [creationdate]-, [Prio] (Priority (1,2,3)) and a calculated [Days Open] column, among many irrelevant others. I need to create a chart that displays the average days a case was open by priority of the case.
To display the average "days required" per (opening-) month for the past 18 months, I created the following measure:
Prio 1 = CALCULATE(AVERAGE('SourceName'[Days Open]),'SourceName'[Prio]=1)
Then I used that as a value, and used the [creationdate] as the x-axis. (Later I changed the x-axis to a new date table linked to [creationdate] without it making a difference.) To display this as monthly averages, I used the hierarchy limited to years and months, and went down one level in the chart.
Something seemed off so I checked first in Excel, then in the data source in PowerBI and yep: The averages in the PowerBI chart are complete bullshit.
Where did I go wrong? I assume it has something to do with the date hierarchy... So I created a date table as recommended (which....why?!) and linked it. That didn't make a difference.
Meanwhile in the data panel if I filter by the date column and calculate the average with the filtered selection of numbers externally, everything works as expected, so its not like there's a date formatting issue.
Do I have to create a calculated column with something akin to
DATE(YEAR([DateColumn]),MONTH([DateColumn]),1)
, then use that as the x-axis without the hierarchy, and hope nobody cares about the day in the label? Or is there something wrong with the measure used? I'm completely lost.

How to Calculate Variance with PowerBI DAX Waterfall Chart

I've sifted through threads and videos trying examples, but I still seem to be stuck. Please help? DAX newbie here.
I have a data set with yearly sales with granularity by geography, device type, and another column with ~6 different technical specifications. I would like to display a dynamic waterfall chart that shows yearly changes in sales based on selected slicers/filters in the workbook.
1) Resolve in one step
=CALCULATE(SUM(Data[$]))-CALCULATE(SUM(Data[$]),PARALLELPERIOD(Data[Date],-1,YEAR))
2) Create an intermediate value for last year sales and subtract from this year's sales
LY Sales = CALCULATE(SUM(Data[$]),DATEADD(Data[Date],-1,YEAR))
VARIANCE = [$] - [LY Sales]