My Sales per Month visual looks like the first part of the picture.
To show the running total of transactions I use this Measure:
Sum Sales Running Total =
CALCULATE(
COUNTROWS(SalesTable),
FILTER(
ALLSELECTED(SalesTable),
SalesTable[CreatedOn] <= MAX(SalesTable[CreatedOn])
)
)
If I choose only one year by slicer I get a correct visual for the running total. As you can see on the picture.
But if I choose multiple years by slicer for the running total visual, the visual adds all the data up instead of overlapping the graphs. See the lower part of the picture.
The correct sum of transactions is marced green and the wrong sum is marced red.
How can i prevent the visual form summing up the running totals in the visual?
Hi This behavior is happening because of the group by. modify the measures are below.
Count of Booths Running Total =
CALCULATE(
COUNTROWS(dlg_V_Booth_per_Event),
FILTER(
ALLSELECTED(dlg_V_Booth_per_Event),
dlg_V_Booth_per_Event[CreatedOn] <= MAX(dlg_V_Booth_per_Event[CreatedOn])
&& dlg_V_Booth_per_Event[RunningMonth] <= MAX(dlg_V_Booth_per_Event[RunningMonth])
&& dlg_V_Booth_per_Event[EventName] = max(dlg_V_Booth_per_Event[EventName])
)
)
Sum of Booth Space Running Total =
CALCULATE(
SUM(dlg_V_Booth_per_Event[BoothSpace]),
FILTER(
ALL(dlg_V_Booth_per_Event),
dlg_V_Booth_per_Event[CreatedOn] <= MAX(dlg_V_Booth_per_Event[CreatedOn])
&& dlg_V_Booth_per_Event[RunningMonth] <= MAX(dlg_V_Booth_per_Event[RunningMonth])
&& dlg_V_Booth_per_Event[EventName] = max(dlg_V_Booth_per_Event[EventName])
)
)
Related
I'm trying to create a chart with 3 informations:
Total cases
% of total per day
cumulative % running total
The first two informations are working, but I can't make the third one work, my chart look like this
And I need it to look like this
Basically, the upper line is a cumulative sum of the lower line, the problem is that the values of the bars are just a count on my table and the lower line I made using the PowerBI function "Show as % of total"
I've tried googling but no luck with this one, tried this measure but didn't work:
Running Total MEASURE =
CALCULATE (
COUNT ( 'Primes Encerrados'[Nome Cliente] ),
FILTER (
ALL ( 'Primes Encerrados' ),
'Primes Encerrados'[Data] <= MAX ( 'Primes Encerrados'[Data] )
)
)
Use a the Quick Measure feature to get your running total formula:
Power BI will generate this formula for you:
Primes encerrados running total in Dias =
CALCULATE(
SUM('Geral'[Primes encerrados]),
FILTER(
ALLSELECTED('Geral'[Dias]),
ISONORAFTER('Geral'[Dias], MAX('Geral'[Dias]), DESC)
)
)
Add the measure to your chart and show it as % of Grand Total like you did with the first line
Hi everyone,
I'm still new to PowerBI, right now I have a set of data in PowerBI as shown in the screenshot above. I have a Measure to calculate the % of OK:
total_student = COUNT(StudentAns[Name])
ok_% =
VAR OK_COUNT = COUNTROWS(
FILTER(
StudentAns,
StudentAns[Answer] = "OK"
)
)
RETURN (OK_COUNT/StudentAns[total_student])
I created a Matrix to show the % of OK for each month as shown in the screenshot below:
What I want to find is the average percentage for all the months. So the final output answer should be 89.05%, which is the average of 85.95%, 91.4%, 89.27% and 89.58%.
The reason I want to get the average percentage of OK across all the months is because I want to use the output as a Target Goals for KPI visualization.
Any help or advise will be greatly appreciated!
You can add one more measure to the matrix as follows:
ok_2 % =
IF(
HASONEVALUE( 'StudentAns'[Month] ),
[ok_%],
AVERAGEX(
VALUES( StudentAns[Month] ),
[ok_%]
)
)
It calculates your original measure for each month, but for the Totals it returns the average of results of your measure.
HASONEVALUE returns True if there is only one distinct value in the filtered context; VALUES - creates a list of unique values; AVERAGEX - calculates the average of a set of expressions evaluated in each row.
This is table: Customer
And this is table Transactions:
They are related by No.
I want the running total of Esaldo:
So:
Running total =
CALCULATE(
SUM(Transactions[ESaldo]),
FILTER(
ALL(
Transactions),
Transactions[Date] <= MAX(Transactions[Date])
)
)
This is wrong:
Due to the external filter (slicer).
So, this should do it:
Running total 2 =
CALCULATE(
SUM(Transactions[ESaldo]),
FILTER(
ALLEXCEPT(Transactions, Transactions[no]),
Transactions[Date] <= MAX(Transactions[Date])
)
)
If the ALLEXCEPT was meant to be understood... It should remove all the filters from Transactions, and preserve the filter in column No.
But it wasn't and thus the result is the same:
So, maybe... ALLSELECTED?
Running total 3 =
CALCULATE(
SUM(Transactions[ESaldo]),
ALLSELECTED(Transactions[no])
)
Nope:
EDIT:
Here's the link to the pbix file:
https://drive.google.com/drive/folders/1W5cnLtIBD9REYbr3VdhIZqTcCtxz62hp?usp=sharing
Dear #nuno if i am not mistaken you might have already found the solution with this code
Running total 2 =
CALCULATE(
SUM(Transactions[ESaldo]),
FILTER(
ALLEXCEPT(Transactions, Transactions[no]),
Transactions[Date] <= MAX(Transactions[Date])
)
)
If you look closer you will see that from your prints runnig total 2 is actualy doing its calculation correctly by adding each invoice per row.
But the 166k that you see at the end is actually not suming the values above. It actually aplying the same measure to the entire table (another evaluation context) which is in fact correct to and is exacly the same as SUM(Transactions[ESaldo]) with no filters.
Nonetheless, given the nature of the example, this total is useless if your goal is to present as a table. you probably want the totals to be consistent.
Try the code below where i try to change the evaluation context inside calculate (sorry but the link above to pbix doesn't seem to work)
Running total 2 =
CALCULATE(
CALCULATE(
SUMX(
VALUES(Transactions[Date]),
CALCULATE(
SUM(Transactions[ESaldo])
)
)
)
FILTER(
ALLEXCEPT(Transactions, Transactions[no]),
Transactions[Date] <= MAX(Transactions[Date])
)
)
Does it work? it should change the context surrounding the date column and correct the total at the end
Trying to create a measure that will count distinct projects that have hit at least one mark
It seems like a simple question but whatever I try in DAX nothing sticks.
Create a measure as below-
total project =
CALCULATE(
DISTINCTCOUNT(your_table_name[project]),
FILTER(
ALL(your_table_name),
your_table_name[mark1] +
your_table_name[mark2] +
your_table_name[mark3] +
your_table_name[mark4] +
your_table_name[mark5] >= 1
)
)
You can use the above measure in a CARD to get the total count of Project name at least has 1 mark in the row. For your sample data, you will get the result 3 (A,C,D).
I need to calculate a running total of a measure by date and by source. Below is a screenshot how my table looks like now.
Below is the measure code.
CashPosition_Revenue Running Total = CALCULATE([CashPosition_Revenue],FILTER(VALUES(FilterKeys_Date[Date]), FilterKeys_Date[Date] <= MAX(FilterKeys_Date[Date])))
I need last column to be calculated as running total.
Using Values limits your filter context to the current date only, try using All to remove that filter:
CashPosition_Revenue Running Total =
VAR CurrentDate = MAX(FilterKeys_Date[Date])
RETURN
CALCULATE(
SUM(FilterKeys_Date[CashPosition_Revenue]),
FILTER(
ALL('FilterKeys_Date'),
FilterKeys_Date[Date] <= CurrentDate
)
)