How to create a Cumulative count in Power BI - powerbi

Hello I am a beginner in Power BI and would need your help.
I have a data at my end and I need to have Cumulative count of my data based on Month.
ID
Code
DATE
GENDER
Cumulative Count
1
A
5/30/2022
M
1
2
A
5/31/2022
F
3
3
A
5/31/2022
M
3
4
A
6/1/2022
F
2
5
A
6/1/2022
F
2
6
A
6/2/2022
M
3
Cumulative Count column above is the output that I am expecting to create in Power BI. Here I have created it manually.
On 30th May total count was 1 then on 31st May count was 2 hence value is 3. Once the month ends and new month starts it should start from 0 and hence on 1st June there are 2 observation and hence total count is 2 and so on.

Try this
CALCULATE(
COUNTROWS('Table')
,ALLEXCEPT('Table','Table'[Date])
,DATESMTD('Table'[Date])
)

Related

How do I make my Power BI table dynamic to change with the filters the user selects?

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]))))

Microsoft Power BI: RANKX AND AGGREGATION OF RESULT

I am having an issues ranking a set of rows then getting the total to use as input to another calculation. I have attempted nested CALCULATE statements and intermediate table using CALCULATETABLE unsuccessfully.
Scenario is as follows:
Original table
Item Sales
A 3
B 4
C 2
D 7
E 5
Ranking top N (3)
Item Sales
D 7
E 5
B 4
TOTAL 16
In this example, I am interested in the value 16 for onward processing
Create a CALCULATED COLUMN to rank the sales.
Sale Rank = RANK.EQ(SalesData[Sales], SalesData[Sales])
Create a MEASURE to get the top 3 sales.
Top 3 Sales = CALCULATE(SUM(SalesData[Sales]), SalesData[Sale Rank] <= 3)

Power BI - How to find a maximum value from a list of sum

In PowerPivot function or Power BI, for data set
article channel qty
1 a 5
1 b 8
1 c 10
2 a 6
2 b 9
2 c 12
I want to create a measure "Maximum net" stands for the maximum net qty of 2 articles in all channels(including "a", "b" & "c").
How to make the measure first sum up all the qty of 1 & 2 articles then find the maximum value of the 2 sums?
I tried to use the following DAX code
=MAXX(VALUES("table[article]"),SUM([qty]))
but the final output is 50. What I suppose the formula do should be the first sum on 2 articles get the "5+8+10=23" & "6+9+12=27", then find the maximum of "23" & "27" and finally get "27"
The DAX below first groups on article and then takes the max:
Measure = MAXX(GROUPBY('table';'table'[article];"total";SUMX(CURRENTGROUP();'table'[qty]));[total])
You can also go with a seperate table and use this:
ArticleTable = GROUPBY('table';'table'[article];"total";SUMX(CURRENTGROUP();'table'[qty]))

Power BI Measure: Aggregate By, Filter By, Group By, Simple Math

I am attempting to make a measure that calculates:
SUM(Num_Compliant) / SUM(Num_Asked) for a District, filtered to the current Fiscal Year (i.e. Date on or after 07/01/2018, or July 1, 2018).
District Date Section Num_Compliant Num_Asked
A 11/12/2018 I 3 8
A 1/12/2018 I 3 8
A 11/17/2018 II 1 6
A 5/18/2018 II 3 6
B 2/20/2019 I 4 8
B 4/20/2018 I 5 8
B 11/12/2018 II 6 6
B 1/12/2018 II 1 6
C 11/17/2018 I 2 8
C 5/18/2018 I 3 8
C 4/20/2018 II 5 6
With the above sample data, I expect the following results
District Numerator Denominator Value
A 4 14 0.29
B 10 14 0.71
C 2 8 0.25
I intentionally made the denominator different in district C to reflect the fact that sections are sometimes missing.
I have been trying to solve this for about a day, and am brand-new to Power BI, so I apologize if this is a very simple question.
The following measure looks like it solves your needs:
Value =
var __date = DATE(2018,7,1)
var __Numerator = CALCULATE(sum(Compliancy[Num_Compliant]),ALLEXCEPT(Compliancy,Compliancy[Distict]),Compliancy[Date]>__date)
var __Denominator = CALCULATE(sum(Compliancy[Num_asked]),ALLEXCEPT(Compliancy,Compliancy[Distict]),Compliancy[Date]>__date)
return __Numerator/__Denominator
Please note you will have to change "Compliancy" to your table name throughout the DAX formula. Also, the date is currently hard coded into the DAX, it might be best to use a date slicer so you can change the values on the fly. The measure without the date filter hard coded as is as follows:
Value =
var __Numerator = CALCULATE(sum(Compliancy[Num_Compliant]),ALLEXCEPT(Compliancy,Compliancy[Distict]))
var __Denominator = CALCULATE(sum(Compliancy[Num_asked]),ALLEXCEPT(Compliancy,Compliancy[Distict]))
return __Numerator/__Denominator
Table in Power BI:
As a side note of things to watch out for:
The measure "Value" needs to be set to the format "Decimal Place"
with 2 decimals.
The date field must be appropriately set to the
"Date" data type.

Calculate latest date for every index with DAX

I have a dataset in Power BI like this
ID DATE
1 06/24/2016
1 06/24/2017
1 06/24/2018
2 08/08/2017
2 08/08/2016
3 12/12/2015
I would like to create a calculated column with DAX, in which i have to calculate the latest date for every index, but I am only able to get the latest date of all the dataset or the same date for every row.
The output should be this:
ID DATE MAXDATE
1 06/24/2016 06/24/2018
1 06/24/2017 06/24/2018
1 06/24/2018 06/24/2018
2 08/08/2017 08/08/2017
2 08/08/2016 08/08/2017
3 12/12/2015 12/12/2015
MAXDATE = CALCULATE(MAX(Table1[Date]);FILTER(Table1;Table1[ID]=EARLIER(Table1[ID])))