I have a "data" table and there is an column "period" -
period
1 year
3 year
1 year
2 year
3 year
3 year
I want my output to be -
year
count
1 year
2
2 year
1
3 year
3
please help me to get this output
Create a new table:
newTable = SUMMARIZE(
Tabelle, /// select table
Tabelle[period], ///
"Count", /// give name for value col
COUNT(Tabelle[period])) /// define function
Output:
Related
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])
)
I have a requirement where I have a data like this,
Date Name Age
1-1-2018 A 1
2-2-2018 B 1
3-3-2018 B 1
6-6-2018 C 2
7-7-2018 B 6
I am trying to give a slicer to the user to select the required number of months from the last month.
So to do that, I am using a calculated column like this:
Month Year = DATEDIFF((Table1[Date]), TODAY(), MONTH) + 1
So that changes the data to something like this:
Date Name Age MonthYear
1-1-2018 A 1 7
2-2-2018 B 1 6
3-3-2018 B 1 5
6-6-2018 C 2 2
7-7-2018 B 6 1
The user selects the Month Year from the Slicer.
For example, when he selects 2, I want to display the last 2 months records in the table.
Expected Output:
Date Name Age
6-6-2018 C 2
7-7-2018 B 6
This works for me if I hardcode it like this:
Calculated Table = CALCULATETABLE(Table1,
FILTER(Table1, OR(Table1[MonthYear] > 2, Table1[MonthYear] = 2)))
But it fails when I try to pass the value in the place of 2 dynamically through a measure using SelectedValue function.
Calculated columns and calculated tables cannot reference a slicer value since they are only computed when you load your data.
If you want to apply this filtering to a visual, I'd suggest creating a separate table for your slicer. For example, you could use Months = GENERATESERIES(1,12) and then rename the column Months as well.
Use the Months[Months] column for your slicer and then create a measure which references it to filter your table/matrix visual.
Filter = IF(SELECTEDVALUE(Months[Months]) >= MAX(Table1[Month Year]), 1, 0)
Then use that measure in your Visual level filters box:
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])))
SalePersonId Month Qty
1 Jan-18 5
2 Jan-18 7
1 Feb-18 1
2 Feb-18 8
3 Feb-18 12
I need to create a measure which gives me a count of salespersons whose total sales quantity is more than 10 for the year 2018.
The result should be 2 (Sale person 1 & 3)
I can achieve this in T-SQL with the following query:
SELECT COUNT(Distinct EmpId) FROM T1 GROUP BY UserId HAVING SUM(Qty) > 10
How can I do the same in DAX?
Here's one possible approach:
= COUNTROWS(
FILTER(
SUMMARIZECOLUMNS(
T1[SalePersonId],
"Total", SUM(T1[Qty])),
[Total] > 10))
The SUMMARIZECOLUMNS part is essentially
SELECT SalePersonId, SUM(Qty) AS 'Total' FROM T1 GROUP BY SalePersonId
The FILTER part is equivalent to the HAVING clause and then you just count the rows in the resulting table.
I am bothered with a simple question.
I need to get the last business day of the month and the date in my dataset only includes the business day.
For example:
ID Date
1 20180301
1 20180302
1 20180305
...
1 20180329
1 20180330
1 20180402
...
2 20180301
2 20180302
2 20180305
And I need the output like this:
ID Date Enddate
1 20180301 20180330 (The last business of March)
1 20180302 20180330
1 20180305 20180330
...
1 20180329 20180330
1 20180330 20180330
1 20180402 20180430 (The last business of March)
...
2 20180301 20180330 (Same for other IDs)
2 20180302 20180330
2 20180305 20180330
I tried to use this command:
enddt=intnx('month',date,0,'E');
However, it will output 20180331 instead of 20180330.
So I was wondering if there is a method to extract directly the last day of given month instead of the calendar month.
Thank you very much for your kind help.
You can do this in a data step:
1) sort on date from latest to earliest (reverse sort)
2) create a variable based on the yearmonth = int(date/100)
3) do a datastep by yearmonth and retain enddate
4) if first.yearmonth then enddate = date;
5) drop vars you don't want
6) sort back to original order