DAX create projection line on a timeline in a line chart by creating a calculated table (or other solution) - dax

I have columns: project, target value, start date, end date. I'm able to calculate column target per day based on the project period.
Starting from the below data
I'd need something like this:
To draw some linear projection like the black one below:
My approach would be to create calculated table and fix relationship to common calendar to create above but maybe there is better solution.
Please help to create such table or any other solution.

So I moved back to data transformations in M - created there table with project start date and end date. Then used below formula to create consecutive date rows in the date range in the desired output column:
=List.Dates([start date], Number.From([end date]-[start date])+1, #duration(1, 0, 0, 0))
then in DAX I used standard LOOKUPVALUE for assigning per day target value from another table so that output table looks like this:
to finally create cumulative measure on 'target cumulative' for the chart purpose:

Related

D365/Dataverse - Create Calculated/Look Up Column that is set to the highest date in another table

I have Table 1. It is filled with dates a inspection is going on. Plumbing or Garden inspections for example.
Table 2 links to these appointments and has additional columns with details such as a Person assigned to the inspection, and what property the inspection is at. I need these two tables to be separate as described, and they are linked by a simple ID column.
Is it possible at all to add a column to Table 2 called 'Last Date of Plumbing Inspection'. The idea is for any given Property in Table 2, there can be multiple inspection entries in Table 1 for it. The point of this column is that it should look in Table 1, find the matching ID, find the latest inspection date out of all the Plumbing-related inspections, and then set the column value to that.
The problem I am having with this is it seems like calculated columns can ONLY implement logic using the columns of the table the calculated column was created in. In Table 2, I can't create a calculated column that interacts with Table 1 at all. I could create a look up column, but I can't combine calculated columns with look up columns. Is there a way to build this latest inspection date column without too much complexity?
Actually you can create a Rollup field and put a MAX aggregate function for achieving your requirement from related table. Read more

PowerBI groupby with filters

My company has tasked with slicing the information on turnover and to create different graphs.
My source data looks like this: Relevant columns are: Voluntary/Involuntary, Termination Reason, Country, Production, and TermDateKey
I am trying to get counts using different filters on the data. I managed to get the basic monthly total using the formula:
Term Month Count = GROUPBY('Turnover Source','Turnover Source'[TermDateKey],"Turnover Total Count", COUNTX(CURRENTGROUP(),'Turnover Source'[TermDateKey]))
This gave me a new sheet with the counts for each month.
Table that shows TermDateKey on Column 1, and Counts on column 2
I am trying to add onto this table by adding counts but using different filters.
For example, I am trying to add another column that gives me the monthly count but filtered for 'Turnover Source'[Voluntary/Involuntary]=="Voluntary". Then another column for 'Turnover Source'[Voluntary/Involuntary]=="Involuntary" and so on. I have not found anywhere that shows me how to do this and when I add in the FILTER function it says that GROUPBY(...) can only work on CURRENTGROUP().
Can some one point me to a resource that will give me the solution I need? I am at a loss, thank you all.
It looks like you may not be aware that you don't have to calculate all possible groupings with DAX formulas.
The very nature of Power BI is that you use a column like "Termination Reason" on an X axis or in the legend of a visual. Any measure that you have created on values of another column, for e.g. a count of all rows, will then automatically be calculated to be grouped by the values in "Termination Reason", giving you a count of each of the values in the column.
You do NOT need DAX functions to calculate the grouping values for each measure for each column value combination.
Here is some simple sample data that has been grouped into dates and colours, one chart showing a count of each colour and one chart showing a sum of the Value column. No DAX was written for that.
If your scenario is different, please explain.

How to create a measure in Power Bi dax which is to be related to Date Column in matrix

I want to make the following table with such data:
Columns: Dates from the selected week(based on calendar table) in WeekMonth slicer
Subcon: Subcontractor distinct list, created with power query from the Subcontractor values in the data table
Plan and Actual: count of set dates, which were set in the data table which looks like:
siteid, subcontractor, milestone, plan date, actual date
Milestone slicer allows to filter data table for a specific milestone and is linked to datatable[milestone]
WeekMonth slicer allows to filter data table for a specific week, only one week can be displayed in the table, by default the "current week is selected".
Filtering data table using the Relatationships between the Calendar[WeekMonth] and the data table is not possible because it contains two types of dates.
As I understand the DAX measures for Plan and Actual must be designed in a such way so it would refer to the date from the matrix Column. How this can be implemented?
How the table must look like(values are not correct yet!):
"Filtering data table using the Relatationships between the
Calendar[WeekMonth] and the data table is not possible because it
contains two types of dates."
It is actually possible to filter multiple date fields by one calendar table in Power BI.
The way it works:
Connect your Calendar table to plan date field;
Connect the same Calendar table to actual date field. Power BI will add this second relationship as "inactive", as indicated by the dotted line;
Normally, when you use your week slicer, it will filter DAX measures by the active connection only (plan date). However, you can tell DAX to filter by the inactive connection instead, using USERELASHIONSHIP function.
Code typically looks like this:
Metric by Plan Date = SUM(TableName[Field])
Metric by Active Date =
CALCULATE( [Metric by Plan Date], USERELASHIONSHIP(Calendar[Date], TableName[Actual Date])
Here, you first define your DAX measure normally, and it will calculate using Plan Date. Then, you recalculate the same measure using different relations (Active Date).
This article might help you further:
https://radacad.com/userelationship-or-role-playing-dimension-dealing-with-inactive-relationships-in-power-bi

QlikView add Calculated Dimension within a Table

Hi Guys I am trying to create a table in Qlikview that shows me sales starting from current week (Week 11) and works back Week 10 Week 9 etc to week 52 previous year. I can do this by creating individual expressions but this would be extremely time consuming. I have been trying to write an expression but having no joy. Is there a way i can create these columns within the table using calculated dimension where i can write a formula, something like:
= sum({=$(=Week(today()-52))<=$(=Week(today()))"}>} QTY)
That would create each week and show the qty of sales.
I would use a numeric representation in the script:
create a field in your calendar: year(date)+Num(Week(MyDate), '00') as yearweek
then you can create a variable vStartWeek: =(max(Year)-1)&52
then your expression will be = sum({<yearweek={">=$(vStartWeek)"}>} QTY)
no need for <=Week(today()) unless you already sold something in the future ;D

SSRS Tablix Cell Calculation based on RowGroup Value

I have looked through several of the posts on SSRS tablix expressions and I can't find the answer to my particular issue.
I have a dashboard I am creating that contains summary data for various managers. They are entering monthly summary data into a single table structured like this:
Create TABLE OperationMetrics
AS
Date date
Plant char(10)
Sales float
ReturnedProduct float
The data could use some grouping so I created a table for referencing which report group these metrics go into looks like this:
Create Table OperationsReport
as
ReportType varchar(50)
MetricType varchar(50)
In this table, 'Sales' and 'ReturnedProduct' are the Metric column, while 'ExecSummary' or 'Quality' are ReportType entries. To do the join, I decided to UNPIVOT the OperationMetrics table...
Select Date, Plant, Metric, MetricType
From (Select Date, Plant, Sales, ReturnedProduct From OperationMetrics)
UNPVIOT (Metric for MetricType in (Sales, ReturnedProduct) UnPvt
and join it to the OperationsReport table so I have grouped metrics.
Select Date, Plant, Metric, Rpt.MetricReport, MetricType
FROM OpMetrics_Unpivoted OpEx
INNER JOIN OperationsReport Rpt on OpEx.MetricType = Rpt.MetricType
(I understand that elements of this is not ideal but sometimes we are not in control of our destiny.)
This does not include the whole of the tables but you get the gist. So, they have a form they fill in the OperationMetrics table. I chose SSRS to display the output.
I created a tablix with the following configuration (I can't post images due to my rep...)
Date is the only column group, grouped on 'MMM-yy'
Parent Row Group is the ReportType
Child Row Group is the MetricType
Now, my problem is that some of the metrics are calculations of other metrics. For instance, 'Returned Product (% of Sales)' is not entered by the manager because it is assumed we can simply calculate that. It would be ReturnedProduct divided by Sales.
I attempted to calculate this by using a lookup function, as below:
Switch(Fields!FriendlyName.Value="Sales",SUM(Fields!Metric.Value),
Fields!FriendlyName.Value="ReturnedProduct",SUM(Fields!Metric.Value),
Fields!FriendlyName.Value="ReturnedProductPercent",Lookup("ReturnedProduct",
Fields!FriendlyName.Value,Fields!Metric.Value,"MetricDataSet")/
Lookup("Sales",Fields!FriendlyName.Value,Fields!Metric.Value,
"MetricDataSet"))
This works great! For the first month... but since Lookup looks for the first match, it just posts the same value for the rest of the months after.
I attempted to use this but it got me back to where I was at the beginning since the dataset does not have the value.
Any help with this would be well received. I would like to keep the rowgroup hierarchy.
It sounds like the LookUp is working for you but you just need to include the date to find the right month. LookUp will return the first match which is why it's only working on the first month.
What you can try is concatenating the Metric Name and Date fields in the LookUp.
Lookup("Sales" & CSTR(Fields!DATE.Value), Fields!FriendlyName.Value & CSTR(Fields!DATE.Value), Fields!Metric.Value, "MetricDataSet")
Let me know if I misunderstood the issue.

Resources