PowerBI - Pivot Rows on Matrix Visualization - Month + 1 - matrix

I have a dataset in the following format. Notice InitialDate of July
2022 has 1 corresponding row of RollingDate and Churn, June 2022 has
2 corresponding rows, May has 3 etc etc
Which I'm looking to display the results in a table matrix like this.
The issue I'm finding it is that if I just use RollingDate as the
Columns and Churn as the Values, it looks like this
But what I want is this

Add a Rank column to the table as follows:
Rank =
VAR __InitialDate = 'Table'[InitialDate]
RETURN
RANKX(
FILTER( Table , Table[InitialDate] = __InitialDate ),
Table[RollingDate],
,ASC
)-1

Related

Calculate the difference between the current and the previous row in DAX

In Analysis Services I have a table for Covid Cases, as shown below:
It shows the cumulative cases on a daily basis for 193 different countries. I would like to add a calculated column to calculate the difference between the current row and the previous row, so I can see the daily new cases. Also, as column Country/Region contains 193 different countries, this calculation needs to be somehow grouped for each country. The Date column should also be in the right order.
How should I sort the table and what DAX function should I use to make this work?
Try this
Column =
VAR current =
CALCULATE ( MAX ( tbl[Value] ) )
VAR prev =
MAXX (
FILTER (
tbl,
tbl[Country] = EARLIER ( tbl[Country] )
&& tbl[Date] < EARLIER ( tbl[Date] )
),
tbl[Value]
)
RETURN
current - prev

creating a static measure to get values in power bi dax

I have the below two tables in power bi as below
based on the above two tables I want to create a matrix visual that should look like the image below "Output Matrix":
I also have a slicer for a month, based on the month column from Table 1, what I want is in the output matrix visual the "Total Users" should remain constant value when we change the month and the rest of the columns values change based on the month selected in the slicer.
Create the following 3 measures:
Measure 1
Active Users = DISTINCTCOUNT( Table1[user_id] ) + 0
Measure 2
Total Users = COUNT( Table2[user_id] ) + 0
Measure 3
Active Users % = DIVIDE( [Active Users], [Total Users], 0 )
Then create a Matrix Visual and drag the Manager column and the 3 measures.
This is the final output:

TOPN DAX function not working. The formula is returning all the rows and not TOP 3

My goal is to create measure to get top 3 customer Names and there respective sales.
I am using the below measure to bring top 3 names along with there sales. The below measure is returning all the rows. I fail to understand why this is happening and why filtering is not happening for top 3 customers
topN = calculate(sum(Sale[Total Excluding Tax]),
TOPN(3,
values(Sale[Employee Name]),
calculate(sum(Sale[Total Excluding Tax]))
)
)
Sale[Employee Name] is calculated column and is coming from another table Employee by using Employee Name = RELATED(Employee[Employee])
The DAX is working properly and grabbing top 3 records. Order/sorting is important. You need to order your results.
Create a calculate column [Total Excluding Tax] to sum up the Total excluding tax. Then use that column in a measure; try something like:
Top Sales = TOPN ( 3, ALLSELECTED( 'Sale' ), [Total Excluding Tax]), desc)

Calculate last year group by ID with DAX

I have a table in SSAS Tabular Model like this
Table 1
ID END 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 Mesure in DAX, in another related Table. The output should be this:
Table 2
ID MAXYEAR
1 2018
1 2018
1 2018
2 2017
2 2017
3 2015
PLEASE !!! WITHOUT USING EARLIER. Because my model is very large, and canĀ“t use this function.
Create a relationship between the 2 tables, assuming that Table 2
contains unique values for ID.
Create a year column from end date
Year = year([END DATE])
After that, in Table 2 create a calculated column with the following code:
MaxYear = CALCULATE(max('Table'[Year]))
Table 2 should look like this

Different number of rows for different columns per page

I have a SSRS report in which there are 3 columns each contain 3 different subreports in a table. Requirement is 1st subreport column should return 27 rows, 2nd : 25 rows and 3rd:26 rows. Is it possible in SSRS ? If yes How ?
You can do this.. using row_number and Mod.
I'm simply generating a list of numbers from 1 - 100 below.. lets assume that this is your dataset. Create a new column using row_number and partition it by mod 25 (27 or 26 as you require) against this dataset. Now you have a unique value every X number of rows..
declare #start int = 1
declare #end int = 100
;with mycte as (
select distinct n = number
from master..[spt_values]
where number between #start and #end
)
Select
*
,ROW_NUMBER() OVER (PARTITION BY (mycte.n % 25) ORDER BY (n) )rn
from mycte
order by 1,2
Now in SSRS, against each subreport add this column, add a parent group, grouping by this newly generated row number (RN in this case). Remove any columns that SSRS adds after grouping, but keep the grouping..
Set the group property to pagebreak in between each instance of the groups.. Done!

Resources