Power BI DAX - find values at max and min date in matrix - matrix

My Power BI data model:
I have a matrix visual where I want to find value at min date and at max date:
Also I need a date filter. For example, if a user selects 03-04.01.2020 dates in filter, the measure should be recalculated and display this result:

Related

AWS Quicksight - Top10 offices by REVENUE divided by REVENUE

Is there a way to make a metric in Quicksight that is the ratio between TOP10 offices by REVENUE divided by REVENUE.
Thanks
The problem is that if I apply a filter to select the TOP10 offices by revenue in the numerator, the same filter is the apply to the denominator.
It was not clear from your question exactly what you meant by "ratio between TOP10 offices by REVENUE divided by REVENUE" but I have assumed you wanted the TOP N real total revenue by Store alongside the "ratio" or percent of total revenue of ALL revenue, not just the TOP N stores revenue.
To do this you can use the following calculated fields.
Make a calculated filler field to 'partition' by; that is you can use it to make a single partition of the whole data set, e.g. "single_partition_filler":
ifelse(isNotNull(store),1,0)
Make the ratio calculation you want, "Revenue over Total Revenue". The trick here is to use the "PRE_FILTER" aggregation level in the Table calculations so you are getting the sum of revenue by store PRE_FILTER divided by the sum of revenue by all stores (using the filler column) PRE_FILTER:
sumOver(revenue,[store],PRE_FILTER) / sumOver(revenue, [{single_partition_filler}], PRE_FILTER)
Make a table with "Store","Revenue (Sum)" and "Revenue over Total Revenue (Min)" and using a TOP N Filter for Store by Revenue (Sum). See Quicksight example below:
Compare with the same table unfiltered below:
Dataset used:
store,revenue
A,100
B,50
C,40
D,70
E,60
A,35
C,80

Power Bi matrix subtotal is not the sum of the values in the column

I am trying to create a "meetingroom occupancy" matrix in Power BI. The raw data contains bookings per day per Room. The maximum daily available time per room is 12 hours. I have created a Date Dimension Table for the dates.
I have tried to change datatypes, added the available time column in the query editor, added the available time as DAX column and as calculated measure, but all with no success. I have changed the available time for Room B to 1, and the result of the Subtotal was 13, so it looks like subtotals is only summing unique values, but I do not know how to solve this.
Could someone please explain to me what is happening and how I could solve this?
The input data is as follows:
And my Date_Dimension is as follows:
This is the current and desired result:

Dax measure to highlight the difference between slicers

I have a Power BI report that should highlight the difference of ETA column ( see below) by the comparison of 2 snap dates (if the ETA value changes from the date of the first selected date in the slicer, in comparison to the second slicer, the ETA cell should be colorized). I need a DAX measure that would help me do that

Cumulative sum with time-intelligent slicer using dax in powerbi

I'm new to Power BI, and I'm working on this measure to show cumulative sum on specific time period.
The case and what I want:
I have one Calendar table [DateKey], and main data table [Data], they have relationship based on column date.
I need to show a visual of line & clustered column chart and a time slicer, in which cumulative sum of revenue based on the slicer.
For eg: I have revenue table for July, I put out the DateKey[Month] column as slicer, when I choose July, the visual would show the cumulative sum of Revenue in July (from 1st to 31st July)
When I choose August, the visual would show cumulative sum Revenue in August (from 1st to 31st August)
What I tried: I used the following DAX
Cumulative Sum Rev = CALCULATE(
SUM(Data[Revenue]),
FILTER(
ALL(Data),
Data[Date]<=MAX(Data[Date])
)
)
Actual outcome: It did create a cumulative sum line, but it was fine for July. If I choose August in slicer, it would be cumulative sum from July to August. What I expected is the cumulative sum will begin from August, not from July.
I tried another solution, which is using ALLEXCEPT instead of ALL, but it does seems not working for date column (you can see my measures in the pbix files already have it, but to filter another column [Lead_type], which works perfectly fine for another slicer)
Cumulative Sum Rev = CALCULATE(
SUM(Data[Revenue]),
FILTER(
ALLEXCEPT(Data,Data[Lead_type]),
Data[Date]<=MAX(Data[Date])
)
)
Please help to show me where I was wrong.
Here is the link to my pbix file, it include what my visual would be and my measure:
https://1drv.ms/u/s!As4H0zrXywmbhaVFDprZ6RJmFUMbbg?e=l4Wxe5
What you are after is a "Month-to-date" measure. This is a built-in time intelligence function in DAX - you can also make your own version using the correct variables and DAX syntax - this carries more flexibility. However, for this case, this should do the trick:
First add a measure that sums the Revenue column. It is always smart to have these simple aggregating measures - when you use these measures in other measures, they are wrapped in a CALCULATE statement automatically, and this avoids some confusion down the road:
Revenue Amount := SUM ( Data[Revenue] )
Then add a TOTALMTD measure, which takes the first measure as the first argument, and your date column as a second argument. Note: the date column is in your DateKey table - do not use the date column in your fact table for this:
Cumulative sum =
TOTALMTD (
[Revenue Amount] ,
DateKey[Date]
)
You should also read up a bit on calendar tables and the difference between creating a table using ADDCOLUMNS and adding individual calculated columns on top of a calculated table. I would start here: https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

How to get minimum value from range date in DAX

I need to get a calculated measure of the minimum date of a range of values, ie I have a fact table with a date and two measures. When I filter by range date, I need to get the second measure of the minimum date of that range, in the example, the measure 1 of 1st january, something like this:
https://db.tt/6jKBPRCr
The picture on the left is as I have the data in the fact table, data from the right as they should be when I filter from date (from 1st to 6 january). The measure 1 is added for a group, and measure 2 is the minimum value of the range of dates and must be repeated for each resulting record (highlighted).
I need the solution for PowerBI Desktop (DAX)
I would greatly appreciate your help with this.
Thank you for your time

Resources