Please help to get cumulative sum on net sales where Posting type = "Posted"
Only for Posted, we need cumulative sum
Need cumulative sum on net sales where posting type = "Posted"
Use this measure:
running total =
CALCULATE(
SUM('Data'[net sales]),
FILTER(
ALLSELECTED('Data'[month no]),
ISONORAFTER('Data'[month no], MAX('Data'[month no]), DESC)
),
Data[Posting type] = "posted"
)
In case your sample data is not fully representative(?) and you also have different years, add this calculated column first
StartOfMonth = DATE(Data[year], Data[month no], 1)
and change the running total formula to
running total date =
CALCULATE(
SUM('Data'[net sales]),
FILTER(
ALLSELECTED('Data'[StartOfMonth]),
ISONORAFTER('Data'[StartOfMonth], MAX('Data'[StartOfMonth]), DESC)
),
Data[Posting type] = "posted"
)
Related
Im working on a dashboard in PBI and I have the next problem...
I have a card that only have to show the month data. For this I use this measure:
Month Orders = CALCULATE(
DISTINCTCOUNT( 'Data'[ORDER] ),FILTER('Data',
'Data'[Month] = 'Data'[Actual Month]),
ALL('Data Incidentes')
)
I understand that if I use All() filter on a measure, this measure don't change when I apply a visual filter but in my case this change.
So my problem is that I have the card that show the month orders but when i apply a visual filter this data change and I don't want it to change.
I hope you understand my problem and my english jaja.
Month Orders = CALCULATE(
DISTINCTCOUNT( 'Data'[ORDER] ),FILTER('Data',
'Data'[Month] = 'Data'[Actual Month]),
ALL('Data Incidentes')
)
Can you try this instead-
Month Orders =
CALCULATE(
DISTINCTCOUNT( 'Data'[ORDER] ),
FILTER(
ALL('Data'),
'Data'[Month] = 'Data'[Actual Month]
)
)
I tried to make a ranking on a date so that every beginning of a month it resets but I can't get it. the furthest I got is that every month simply gets an cumulative ranking based on RANKX on power bi which includes a month and a year.
Has anyone needed such a ranking and succeeded?
A generalised set-up for a Calculated Column would be along the lines of:
=
VAR ThisMonth =
MONTH( Table1[Date] )
RETURN
RANKX(
FILTER( Table1, MONTH( Table1[Date] ) = ThisMonth ),
Table1[Date],
,
ASC
)
I have a problem of getting the percentage on customer sales in matrix table thta is sliced by store_id and employee_id using ALLEXCEPT function. The percentage of customer sales need to obrain from dividing customer sales measure in current filter by the same measure of the respective store_id, instead of total customer sales of all the store_id.
Here is my expectation of the output and the DAX when using ALL function on the staff_id.
% of Customer Sales =
VAR ALLExceptSales =
CALCULATE(
[Customer Sales],
ALL(
'Employee Lookup'[staff_id]
)
)
VAR Ratio =
DIVIDE(
[Customer Sales],
ALLExceptSales,
BLANK()
)
RETURN Ratio
I have tried using ALLEXCEPT on store_id from sales by store table, ALLEXCEPT store_id from store lookup table and ALLEXCEPT on both the tables, still giving me different output.
Here is the pbix file for testing.
https://drive.google.com/file/d/1fRrfsikHl9aK06GzAozJ9Wc16Ue0YJm2/view?usp=sharing
Anyone can hint me on?
Replace DAX with following
% of Customer Sales =
VAR ALLExceptSales =
CALCULATE(
sum(Table[Customer Sales]),
ALLEXCEPT(Table, 'Table'[store_id])
)
VAR Ratio =
DIVIDE(
sum(Table[Customer Sales]),
ALLExceptSales,
BLANK()
)
RETURN Ratio
Have you tried ALLSELECTED instead of ALLEXCEPT?
% of Customer Sales =
DIVIDE (
[Customer Sales],
CALCULATE ( [Customer Sales], ALLSELECTED ( 'Employee Lookup'[staff_id] ) )
)
I have salesman dimension and sales fact with 1:M relationship on salesman_id.
I am trying to create a measure for count of salesman that have made sales in location is 6.
CALCULATE (
DISTINCTCOUNT ( Salesman[SalesmanKey] ),
Sales,
Sales[LocationId] = 6
)
I think this is not working because the filter doesn't flow from sales into salesman table.
I could change the filter direction as both but I'm looking at other option like using DAX CALCULATE with CROSSFILTER. Is there any other option like using CALCULATETABLE?
You can use the following Dax formula to achieve your goal:
Measure =
CALCULATE(
DISTINCTCOUNT( Salesman[SalesmanKey] ),
CROSSFILTER( Sales[salesman_id], Salesman[SalesmanKey], Both ),
Sales[LocationId] = 6
)
However I recomend you using the salesman id from the fact table:
Measure =
CALCULATE(
DISTINCTCOUNT( Sales[salesman_id] ),
Sales[LocationId] = 6
)
Edit: i added the option using the calculatetable:
Measure =
CALCULATE(
DISTINCTCOUNT( Salesman[SalesmnaKey] ),
CALCULATETABLE(
Sales,
Sales[LotacionId] = 6
)
)
I know how to do cumulative sum if dataset has Dates, But I am struggling to do same if I do not have dates in my dataset.
Below is the data, I want CUM Sales
I've selected New quick measure -> Totals -> Running total and creates this:
sales running total in part =
CALCULATE(
SUM('Query1'[sales]);
FILTER(
ALLSELECTED('Query1'[part]);
ISONORAFTER('Query1'[part]; MAX('Query1'[part]); DESC)
)
)
Returns:
You can also create own measure to calculate cumulative sum.
Select New Measure from the ribbon and write the following expression
Cumm Sales =
VAR Current_Part = MAX(Test[Part])
RETURN
CALCULATE(
SUM(Test[Sales]),
Test[Part]<=Current_Part,
ALL(Test[Part])
)
Output: