Let's say that table looks like this :
id
step
time
1
a
0.5
1
a
0.7
1
b
1
1
b
1.5
2
a
0.9
2
a
0.8
It's super simplified, but as you can see we can have the same ID and step more than once.
The question is how to create a measure in PowerBI ( DAX) to summarize time under two or more conditions without listing all steps and IDs (for example for ID "1" step "a" occurs twice so my sum should be 1.2, step "b" 2.5 etc.)
There is a nice function SUMMARIZE. You can create a table using this function:
Table 2 = SUMMARIZE(ALL('Table'), [id], [step], "time", SUM('Table'[time]))
Related
I have 2 tables in powerbi
Table A
ID
Name
1
Zelu
2
Bezeu
3
Aquino
Table B
ID_A
Class
1
A
1
A
1
B
2
A
And a wish to calculate count of names with class A
like
Zelu - 2
Bezeu - 1
Aquino - 0
There is away to use a DAX function to execute this job?
Thanks a lot!!!
Saulo
I tryed to use calculate function but i donĀ“t know how to link tow tables.
You need to first establish a relationship between your tables that goes from ID in Table A to ID_A in Table B:
Then you simply add a measure:
Count =
COUNTROWS ( 'Table B' ) + 0
Which you can use in a matrix visualization together with 'Table A'[Name] and 'Table B'[Class] to get your desired result:
So, I have two tables, Scores and Accounts.
ID
Score
1
120
2
150
3
100
ID
Account
1
Account 1
2
Account 2
3
Account 3
I also have 4 measures that calculate the quartile percentile for all of the scores in the Scores table. I was wondering if it was possible to have a measure that concatenates the accounts into one line if their score is, for example, greater than the Quartile 1 measure. For example, if quartile 1 is 110, then I want a measure that would give me "Account 1, Account 2". Is this possible?
I managed to get your result by implementing the following measure, assuming you have a relationship between the two tables.
Accounts GT Q1 =
CONCATENATEX(
FILTER(
Scores,
Scores[Scores] > [Quartile 1]
),
RELATED( Accounts[Account] ),
", "
)
Output
There may be a simpler way. Let me know if that worked.
I have a table of calls with a column for phone number and call id. I want to create a visual that shows how many callers called how many times. (e.g. 5 callers called once, 4 called twice etc.) The challenge I am facing is that once I calculate the count of the number of callers that called count times, the table is static and is not affected by the filters on the report (e.g. the date filter).
This is what I have done so far. Is there a better way?
CallerNumber
CallID
DateTime
1
a
2022-01-01
1
b
2022-01-01
2
c
2022-01-02
3
d
2022-01-03
4
e
2022-01-01
4
f
2022-01-05
4
g
2022-01-06
From the above original data, I created a table...
Table1 =
SUMMARIZE(
Query,
Query[CallerNumber],
"Call Count", COUNT(Query[CallId])
)
CallerNumber
Call Count
1
2
2
1
3
1
4
3
and then another table from that table which gave me...
Table2 =
SUMMARIZE (
'Table1',
'Table1'[Call Count],
"Number of Callers", COUNTROWS('Table1')
)
Call Count
Number of Callers
1
2
2
1
3
1
How would I instead show the below if someone were interested in calls on Jan1?
Call Count
Number of Callers
1
1
2
1
Thanks!
CalculatedTable is populated once at powerbi Model refresh, this is why it don't reflect any change in your filters.
A better option is to use a measure:
CountOF = CALCULATE( countrows(VALUES('Table'[CallID])))
Add additional "counter" table with number from 1 to 10 .
how manyCaller = var _virtual = ADDCOLUMNS(VALUES(detail[ids]), "CountOfCalls", [CountOF])
return
CALCULATE( countrows(FILTER(_virtual, [CountOfCalls] = SELECTEDVALUE(counter[CallCount]))))
I have a table with three columns - list_id, id, daily_return. id is basically a number sequence increment, reset for every list_id.
Example:
list_id id daily_return
1 1 0.2
1 2 0.18
1 3 0.35
2 1 0.15
2 2 0.18
2 3 0.23
I need to create a calculated measure on the chart I am creating such that it creates a running total of daily_return for the same list_id, ordered by the id column.
I am creating a measure in the chart, since I want the rows to be filtered by the user and the calculation itself will be more complex.
How do I get the current list_id and id, so I may use it in my formula?
This is what I have so far. I tried using EARLIER/EARLIEST without success.
cumulative_return = CALCULATE(SUM('CMC Daily Return'[daily_return]), 'CMC Daily Return'[list_id]=EARLIER([list_id]), 'CMC Daily Return'[id]<=EARLIER([id]))
I came up with the following formula that works, but if there is a better one, then I am all ears.
cumulative_return = CALCULATE(SUM('CMC Daily Return'[daily_return]), FILTER( ALLSELECTED('CMC Daily Return'), 'CMC Daily Return'[list_id] = max('CMC Daily Return'[list_id]) ), FILTER( ALLSELECTED('CMC Daily Return'), 'CMC Daily Return'[id] <= max('CMC Daily Return'[id]) ) )
Problem
I would like to create a multi-layer histogram that shows the distribution of var1 on the first level and var2 on the second level, with a legend by source, like this:
The value should show the percentage w.r.t. the total of a source, with all the selections and slicers applied. The percentages shown in the histogram should always sum to 100% per source.
Example data
I have the following example data:
source var1 var2 count
A 1 1 100
A 1 2 12
A 1 3 34
A 2 1 1612
A 2 2 23
A 2 3 43
B 1 1 200
B 1 2 320
B 1 3 12
B 2 1 1757
B 2 2 345
B 2 3 32
What have I tried
I can achieve a total per source with the following measure without the filtering part:
percPerSource =
DIVIDE(
SUM(input[count]);
CALCULATE(
SUM(input[count]);
ALLEXCEPT(input;input[source])
)
)*100
If I turn on Drill mode and click on the columns of var1 I get the following, undesired result (the percentages do not sum to 100%):
Another attempt was using the ALLSELECTED function:
percSelected =
DIVIDE(
SUM(input[count]);
CALCULATE(
SUM(input[count]);
ALLSELECTED(input[var1])
)
)*100
This shows only 100% on the var2 level:
I think this will do what you're after:
percPerSource =
DIVIDE(
SUM(input[count]);
CALCULATE(
SUM(input[count]);
FILTER(
ALLSELECTED(input);
input[Source] IN VALUES(input[Source])
)
)
)*100
This takes all the selected values as the universe you are filtering on but only selects the rows that in your local filter context.
The FILTER function takes a table as its first argument and a condition as the second argument. It iterates through every row in the table passed into it and checks if the condition holds and returns a table with only the rows where the condition evaluates to True.
The VALUES function returns a list of distinct values of the column specified evaluated within the local filter context.