I am trying to create a Dynamic Table in Power BI.
I have my set of data, and basically I want the calendar to pick up the minimum date and the maximum date from my table, but only if the maximum date is not the month of today. If the maximum date is the month of today, then it should ignore it and the calendar should be created with the max date of the previous month.
I started the formula, but can't seem to continue it. Any ideas?
Calendar_= CALENDAR(MIN('Table1'[Date]),IF(MONTH(MAX('Table1'[Date]))=MONTH(TODAY()),date(YEAR(MAX('Table1'[Date])),.....
See if this post helps: https://community.powerbi.com/t5/Desktop/Dynamic-table-or-on-fly-table-generation-via-DAX/m-p/434397#M200275. If not, I would simplify by creating some additional calculated columns or measures and then reference those instead of one nice big formula
Related
hope you're doing well.
I'm a newbie to PowerBI and I'd want to convert the decimal time/date column values into hours of the time to plot the info over a 24-hour timeline. I was able to achieve this in tableau and as it automatically detects the hours and can easily be able to plot the info. I was a bit close in achieving this in powerBI as I converted the date/time column to time and tried plotting but there's huge noise and looks more cluttered as it took every change in seconds/minutes (the bottom snippet). I've attached the snippets for reference, can anyone pls try to help me on this ?
In Power BI it's recommended to split the DateTime column into separate Date and Time columns. This is both for performance reasons. Over a year a DateTime column with 1sec granularity can have 30M different values, which is much more data than storing one column with 365 values, and one with 86,400 values. And so that your Date column can link to a Date Dimension to provide other DateTime hierarchy attributes, like FiscalQuarter, DayOfWeek, etc.
In Power Query select the DateTime column and go to --> Add Column --> Time -- > Time Only. Then change the data type of the DateTime column to Date.
This also solves your reporting problem as you can simply put the Time column on the X axis.
If you want a custom format string for the time you can add a calculated column in Power Query like
= Table.AddColumn(#"Changed Type1", "TimeDesc", each DateTime.ToText(#date(2020,1,1)&[Time], [Format="h tt"]))
And configure the new column with a "Sort by Column" of Time.
I am a new user of Power BI and I was wondering if it is possible to calculate the date difference that is present in two different tables but they both are connected to the third table in which I want to create a measure or a column using dax to calculate date difference:
The columns marked in red are dates and I want their difference to be calculated in the assumption table. I used the month number to build the relationship between these tables.
You can use a Measure as below-
date_diff =
DATEDIFF(
RELATED(d_nl[notification]),
RELATED(d_fc[file_closure_date]),
DAY
)
To know about other Intervals rather than DAY, you can visit Here.
I am using a slicer to determine a certain periode of time (e.g. 01.10.19 - 31.10.19) and now I want Power Bi to calculate how many days are included (in this case it would be: 31). Of course the calculation needs to be updated every time I use the slicer. Is there any possibility to do so? I have literally no idea...
Create a measure to calculate the difference between the max and min dates in your date table, which is filtered by this slicer. You can use DATEDIFF function for that. In this case the number of days will be calculated as:
Number of days = DATEDIFF(MIN('Calendar'[Date]); MAX('Calendar'[Date]); DAY) + 1
I just want to select a range of days in a slicer and show in a table the number of days for each month/period (month-year).
I used DAX to create a table with the information I need and I don't have problems with the periods (first column), it changes dinamically, the problem is the column "Days" (second column) because it's always showing the total number of days for each month.
Here my DAX code
SelectedPeriods = GROUPBY(DimDate;DimDate[Period];"Days";COUNTX(CURRENTGROUP();DimDate[DateKey]))
Here the result
What I expect is:
2 for april, 31 for may, 1 for june
This is an issue with execution order.
SelectedPeriods = GROUPBY(DimDate;DimDate[Period];"Days";COUNTX(CURRENTGROUP();DimDate[DateKey]))
Generates a calculated table. These are calculated when the data model is refreshed and stored in it. They are not refreshed each time a connected dimension is changed within a dashboard.
In your case, while changing date filters may hide rows from this table the number of days remains fixed at the number calculated initially when there was no filter context on the data i.e. counting all days in the month.
If you want the result to change then you need to use a measure instead of a calculated table. Measures react to the current filter context within the report and so will adjust their output each time a slicer is changed.
The needed measure will depend on your model but might be something as simple as:
CountOfDays := CountRows(DimDate)
let's say I have a KPI which is a simple calculation like
SUMX(FILTER(Table;Table[Date] < Today());Table[Column])
I would like to plot a time series of the KPI's past values (for example for the first day of every month since 01-01-2014), so for instance it is enough to create a new table - Trend_Table - with two columns - DATE, KPI and calculate each row's KPI value as
SUMX(FILTER(Table;Table[Date] < Trend_Table[Date]);Table[Column])
(it may not exactly work that way in DAX but you get the idea)
The problem is I really want to have online values, which means that once the September begins a new row with DATE = '01-09-2018' should be added automatically to the table 'Tren_Table'.
Is it possible in Power BI? Any referalls greatly welcomed.