*SOLVED* How do I sort columns in a Matrix view? - matrix

I am attempting to create a gantt chart in Power Bi using the matrix view, and the end user wants it to have year, quarter, and month. The year and quarter columns are fine, but the month columns are out of order, and I cannot seem to figure out how to put them in order. My calendar table and everything in it are created using dax.
So far, I haven't really tried anything. I am assuming Power Bi is not recognizing them as months in a date table and that is why it is not sorting them accordingly, but alphabetically by quarter and year.

You need a sort by column.
You can read how to create one here.
https://learn.microsoft.com/en-us/power-bi/create-reports/desktop-sort-by-column?tabs=powerbi-desktop

Related

Power Query - DATEADD fails once current year filter applies

Please help. I don't understand why I have 2 similar data models and one works but the other does not.
I have a fact table with a Calendar Key and data as granular by day by location. I have a calendar dimension table with a Calendar key, each individual date, and month/fiscal year definitions.
Measures are Rev = SUM(FactTable[RevColumn]) then Rev PY = CALCULATE([Rev], DATEADD(CalendarTable[Day_Date], -1, YEAR))
Model 1 in Power BI, when I apply date filters, Rev calculates the total revenue & Rev PY calculates last year's rev for same range. Even if I select all dates that are YTD (which is tedious)
Model 2 in Excel 2016 Power Query, when I apply a year filter, Rev calculates total revenue for YTD in Fiscal Year & Rev PY is blank.
I don't understand what is different and why it would even fail in the first place. Calculate is supposed to override the filter context of the current filters right?
Also: the only "Date" type columns are located in the calendar table so it's not possible for me to select the wrong table.
I ultimately had to ask a professor on Udemy.com. The solution is to mark you calendar dimension table as a "Date Table." Since I'm combining the 2 tables on a whole number field, the time intelligence functions only work when filtering with date columns.
By marking the Calendar table as the Date table, the time intelligence functions know to use any attributes from that table to filter down the date ranges and get and display the appropriate answer.
In Power Pivot view, click the "Design" ribbon, then click the "Date Table" button and the "Set Default" button after that.
This resolved all issues I had.

Custom function by date for related tables

"In a crosstab, latest month where Actuals has any data, show Actuals data for that and all previous months. Future months, show Forecast data."
.
I have two tables- Forecasts and Actuals- and the common columns between them are Team, Month, Value.
I'd like to show the data in a crosstab with Month as columns and Team as rows. I'm trying to write an expression to do this in the crosstab: The most recent month where Actuals has any data, I'd like to show Actuals data for that and all previous months, for all teams. For following months, I'd like to show Forecast data.
Any suggestions about how to go about this would be appreciated. I'm still piecing together my knowledge :)
Create a third table from a transformations:
Create Third table from - Pivot date on Team & Month (to ensure every possible combination) from first table
Add Rows from transforming the second table (pivot on Team & Month)
Join the two original tables to your newly created table (has every possible combination of Team & Month) so that both your data sets are now in one table.
Now use the third table in your cross table.
If you try using column matching instead of the above method only dates from the main table will show as the dates are matched and ones missing from the other will not display.

DAX Select a date range in the calendar table

I am looking to select the size of the calendar table, filtering everything before or after some date, much like a slicer does.
I am trying to compute the percentage change between prices of equity indexes between two dates: now and a year ago. The problem is that the same date last year sometimes falls on a non-trading day. In that case I want the code to select the earliest value available.
In a similar situation, where I use a slicer, I implemented this by using FIRSTNONBLANK and LASTNONBLANK functions. This way, if the slicer is set to a non-trading date the system still works.
I am very much a DAX/Power BI novice, interested in the methodology in DAX as much as addressing the current problem.
Thanks in advance.

Building a matrix with columns == days of month when recordset cannot return all days of month

I'm trying to put together an attendance report for a school that tracks student attendance codes for that student for every day on the calendar month in a DynamicsCRM system being used as a managed service (that is to say, I build queries using FetchXML and cannot use SQL). The format for the report requires that a column for every day in the month be listed for the report. My student table that tracks this attendance however only contains records for days where an attendance value is recorded, and I do not have an object available that can return every day in a month for me.
I am looking for a solution other than hardcoding 31 columns and using conditionals to control the display of the last three day columns. Ideally, I'd like a conditional in my matrix column grouping that would look at the date value for the previously generated column and determine if the next date record from my resultset is sequentially the next day of that month, and if not, create the next sequential date, move to the next column and perform the check again until it is true. Is there a way I can do this, or another means to accomplish my goal that does not involve hard-coding day columns into a table or matrix? Right now, I have nothing; I can barely imagine how I think this should look.
What I did to solve the same issue has been to create a scheduled process each day to create a record and deactivate it.
I have then been able to distinguish actual records (the active ones) from these 'placeholders' (inactive ones) in my querying.

Sort Months PowerBI Designer

I am trying to sort months into PowerBI Designer Preview, it looks like it only can be done alphabetically. But when I look on the internet at images of PowerBI it looks like they are all sorted correctly. Can somebody help me? And there must be other people who are facing this problem right?
Thank you in advance.
Check what is the data type of the column you are trying to sort. If it's Text then it would sort alphabetically, irrespective that these are numbers. Make sure it's Date or Number to sort correctly.
In Power Pivot, you can set a sort by column. This hints Power Pivot to sort a given column like a column of month names by another column like a column of integers representing the order of month names. The pattern is to create a Date table - a table with all of your dates. In this date table you create a column with month names and another column with month indexes. Then you select the column with month names and set the sort by property to the month indexes column. Usually, I like to create a 'MonthYear' column that has values like "Dec-14", "Jan-15" etc. this then allows me to sort correctly across years.

Resources