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/
This is my input file, having months of data.
Now I want to create this matrix in the PBIX, with 12 months of trailing data from a date slicer.
That is I will have a date slicer and I want to see the previous 12 months of data from the selected month.
For example, if I select Jan'21 in my slicer I want to have data from Jan'21 to Feb'20.
I watched some of the videos, but those videos focused on measures or rolling average or rolling total, in my case I want columns.
I have no idea how to implement this in Power BI. Thanks.
EDIT:- The Actual Exp and Actual Min column also have N/A for various months.
Hi I am looking to complete a vlookup to determine rate costs. I have created a date calendar that contains bank holidays and created a relationship with my main data set. if a job was completed on a sunday or a bank holiday it would be rate 3 or if it mon-fri after 6pm and anytime saturday then rate 2 and all others rate 1. I have tried completing a vlookup howerver it show an error "DAX comparison operations do not support comparing values of type True/False with values of type Integer". i am only learning power BI and any help would be greatly appreciated.
I have columns that show start day, start hour and true/false if it is a bank holiday (Cant seem to add picture)
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:
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