I have a table that is a summary of my actions for my clients and the time I've spent doing it.
So a row would look like this :
Client | Time |Week of the Year | Action
------------------------------------------
Client 1 | 1 | 1 | Summarize action
Client 2 | 2| 1 | Summarize action
And I Would like to add a column (either a calculated column or a measure) that return the sum of time spent on the selected client for the selected week
So each row that contains "client 1" && "Week 1" show the total amount of time spent during "week 1" for "client 1" and I have no idea how to do that in powerbi ...
Simply adding [Client], [Week of the Year] and [Time] to a new table visual should do the trick. Just make sure that you're not summing the values of [Week of the Year], since it seems to be a numeric column from the example you posted:
Related
I have been working on this Power BI Report and would like some assistance with a slicer used for a matrix.
I need the slicers "MB Data Used", "Calls Made", and "SMS Sent" to slice the Matrix Grand Total fields (on the far right) instead of the value fields. My current slicers work great on the value fields.
Data is filled by a table:
----------------------------------------------------
|ph_id | month | data_used | calls_made | sms_sent |
| 1 | 1/1/19| 123 | 0 | 33 |
| 2 | 1/1/19| 87 | 22 | 0 |
| 3 | 1/1/19| 0 | 0 | 0 |
| 1 | 1/2/19| 0 | 55 | 33 |
| 2 | 1/2/19| 87 | 22 | 77 |
| 3 | 1/2/19| 0 | 0 | 0 |
----------------------------------------------------
Which links to a few others to get related data.
My goal is to be able to see which phone numbers have had no data/call/sms use over the last X months instead of just filtering the ones which contain a 0. In this scenario, when the slicers are all set to 0 and the date range is set 1/1/19-1/2/19, only ph_id 3 should show.
Edit:
W.B. - see this image
You need to use another, unrelated table for your slicers. The best way to create such table is to use the what-if parameter option in the modelling tab (assuming you have any recent version of PBI Desktop).
Or, if you want to base the slicer on number of calls from actual data, you would create the slicer table using New table option and the following formula: CallSlicer = GENERATESERIES(MIN(Data[calls_made]), MAX(Data[calls_made]), 1). The one at the end indicates the step, so you can adjust it, if you want your users to use the slicer in, for instance, increments of 10 or 20.
Now, when you use the generated CallSlicer column, which looks like this:
You will be able to filter your results like this: Your filtered measure = CALCULATE([your_measure], FILTER(Data, Data[calls_made] >= MIN(CallSlicer[CallSlicer]) && Data[calls_made] <= MAX(CallSlicer[CallSlicer]))). You then use your filtered measure in the matrix visual.
EDIT:
Here's a working sample: https://1drv.ms/u/s!AmqvMyRqhrBpgtRGGbJ6w-b66uBENQ?e=67JduS
I've updated the sample - now it shows 2 scenarios. One table reacts to the slicer at individual cell level, the other one at the grand total level.
The key to have the first table working is shown above, below is a solution for the second table, that filters rows at the grand total level:
Create a measure that will show sum for all dates/months, as an example:
CallSumTotal =
VAR tab =
FILTER (
CALCULATETABLE (
SUMMARIZE ( Data, Data[id], "calls_made", SUM ( Data[calls_made] ) ),
ALLSELECTED ( Data[month] )
),
[calls_made] >= MIN ( CallSlicer[Value] )
&& [calls_made] <= MAX ( CallSlicer[Value] )
)
RETURN
SUMX ( tab, [calls_made] )
Now in the matrix use a regular sum measure, but create a visual level filter for CallSumTotal and set it to is not blank
I have the table that looks like this:
Column Header: User | Test Score 1 | Test Score 2 | Test Score 3 | Total Points | Status
Row: Person1 | 50 | 70 | 75 | 195 | Failed
Row: Person2 | 70 | 75 | 85 | 210 | Passed
The "Total Points" column is simply the SUM of the three test scores and the "Status" is calculated based on the "Total Points" (if "Total Points" < 200, "Failed", "Passed").
What I'm having difficulty with is that sometimes a test needs to be eliminated from the equation. I would like the end user to be able to uncheck a box in the filters area or on a slicer to remove a test from the equation for the "Total Points", which would then affect the "Status". Since the test is a column header and not a value, I can't seem to find a way to make this work.
The data table is already in a report layout. That makes your intention difficult to process. A better layout would be a flat table in this format:
Name, Test number, Score
You can use Power Query to unpivot the data to get from your layout to the flat table. With a flat table, you can then build a measure for the total and add a slicer to the report where the test number can be selected.
Build a matrix visual with the Name in the rows and the test number in the columns, the measure for the total in the values. Then use the slicer to remove tests from the matrix at your discretion.
I have im my model table that contains data from reports based on monthly reporting of employees with column names "ReportDate" and enployye numbers.
I want to check that there is no gaps between the monthly dates to each employee with DAX.
For example:
EmpNum | ReportDate | CheckColumn
111 | 30.08.2019
111 | 30.09.2019
111 | 31.10.2019
222 | 30.08.2019
222| 31.10.2019 ----------> Here I want alert in my CheckColumn
Can someone find me a solution?
First you need to create a index column. Go to Edit Queries > Add Column > Index Column, starting with 1 for example.
Next you add a column with DAX which has a shift of 1 to the original column with this expression (make sure this column is from the same date format as your original column; Modelling > Format):
ShiftColumn = DATEVALUE(CALCULATE(MAX('Table'[Report Date]);FILTER('Table';'Table'[Index]=EARLIER('Table'[Index])-1)))
Next add the column with the check:
Column 2 = IF(DATEADD('Table'[Report Date].[Date];-1;DAY) = 'Table'[ShiftColumn]; TRUE(); FALSE())
The result:
I'm new to power BI and i require your assistance. I want to create a visualisation showing the average number of tickets from the previous 3 months and compare it with the current month. Is there any easy way to do this?
I have tried many solutions online but it dosen't work. I think it is because my dataset may not suit the solution.
My data:
Tickets | Date
1 | 6/30/2019
1 | 6/10/2019
1 | 7/1/2019
0 | 7/2/2019
1 | 6/30/2019
There are many more columns and rows. The value of ticket is either 1 or 0 and the date can be repeated. This is the data i received from an API.
This is what i currently have
The data would get bigger and bigger as time goes by.
I would want to add a 3month rolling average line in this current visualization that i have.
Thank you!
Here we go:
First I created a column FirstDayMonth,this I use to group all data of the same month
FirstDayMonth = EOMONTH(Tickets[Date];-1)+1
My table looks like:
Next I create a summarized table grouped by the FirstDayMonth
TicketsMonth = SUMMARIZE(Tickets;Tickets[FirstDayMonth];"Amount"; SUM(Tickets[Tickets]))
I add a column Ave3PrevMonth
Ave3PrevMonth =
var totalMonths = YEAR(TicketsMonth[FirstDayMonth]) * 12 + MONTH(TicketsMonth[FirstDayMonth]) - 3
var periodStart = DATE(totalMonths/12;MOD(totalMonths;12);1)
var periodEnd = TicketsMonth[FirstDayMonth]
return
CALCULATE(SUM(TicketsMonth[Amount]);
FILTER(TicketsMonth; TicketsMonth[FirstDayMonth] >= periodStart && TicketsMonth[FirstDayMonth] < periodEnd))/3
This is the tricky bit as Power bi is not strong with dates..
I added an extra column PeriodStart to show the date from where average is taken:
PeriodStart =
var totalMonths = YEAR(TicketsMonth[FirstDayMonth]) * 12 + MONTH(TicketsMonth[FirstDayMonth]) - 3
return DATE(totalMonths/12;MOD(totalMonths;12);1)
End result:
I currently have a bar graph in power-bi. The graph has distinct id's on the x axis and the amount of mail they received on the y axis. In the Table I am using, I have SalesYear, id, and a Val column which has the value 1 in each row. The id shows up multiple times in the table, sometimes more than twice in the same year.
The problem is I want the graph reversed. I would like to bucket people based on how much mail they received. Then use a slicer to see how much they receive per year. I have been struggling to find a solution on my own, would anyone have any ideas on how to approach this.
Table l looks like this:
id | salesYear | Val
10 | 2012 | 1
11 | 2012 | 1
11 | 2013 | 1
10 | 2012 | 1
10 | 2013 | 1
12 | 2012 | 1
12 | 2012 | 1
So in the visualization I want to show that on the x-axis that people who received 1 piece of mail = 0, 2 pieces of mail = 2, 3 pieces of mail = 1. My question is how can i achieve this will a Stacked Column chart. Any suggestions would be greatly appreciated!
15k | Y axis would be amount of people who recieved 1 piece, 2 piece, etc..
14k | _
13k | | |
12k | _| |
11k || | |
10k ||_|_|_________________________
1 2 3 4 5 6 7 8 9 <-AmountOfMailRecieved
1) Starting with your sample data in Power BI.
2) Create a new calculated table that is a distinct list of years from your source table.
Years = DISTINCT(
SELECTCOLUMNS(
Mail,
"SalesYear", Mail[salesYear]
)
)
3) Create another calculated table that crossjoins the year table with a series of integers. Power BI might indicate the [Value] has an error (like it does for me in the picture below), but it works properly.
MailCounts = SELECTCOLUMNS(
CROSSJOIN(Years, GENERATESERIES(1, 20)),
"SalesYear", Years[SalesYear],
"MailReceived", [Value]
)
4) Add a calculated column that counts the number of IDs in the source table that match the year and mail count. For example, the first row is counting how many distinct IDs show up exactly once in the source table for the year 2012; it's 1 because only ID 11 shows up in 2012 once.
PersonCount = CALCULATE(
DISTINCTCOUNT(Mail[id]),
FILTER(Mail,
Mail[salesYear] = EARLIER(MailCounts[SalesYear]) &&
EARLIER(MailCounts[MailReceived]) = CALCULATE(
COUNTROWS(Mail),
FILTER(Mail,
Mail[salesYear] = EARLIER(Mail[salesYear]) &&
Mail[id] = EARLIER(Mail[id])
)
)
)
)
5) Create relationships between your source table and the year table, and then between the year table and the count table. This will allow the creation of a slicer based on the year of your source table to filter the results from the count table.
6) Optionally, you can hide the year field in the source and count tables. After doing that if you desire, create a chart as configured in the picture below
7) Create a slicer from the year table as shown in the picture below.
And that's it. The chart should match with your expected outcome and can be filtered by year.
You'll be using DISTINCTCOUNT either in a measure or a column.
VariableName = DISTINCTCOUNT([AmountofMailReceived])