Thursday, November 19, 2020

Guy in a Cube - YouTube Videos

 Use DAX to Get Relative Dates: https://www.youtube.com/watch?v=wQ9DohPvx8Q

Making Data Source Parameters Easy: https://www.youtube.com/watch?v=OnaDJkGOmIE


Dynamic Power BI reports using Parameters: https://www.youtube.com/watch?v=iiNDq2VrZPY

Call stored proc, get parameters from Excel.


Populate a Power BI parameter list using a query



The How and Why of Power BI Aggregations


Configure Power BI Aggregations



How to Use the Power BI Aggregation Features - Christian Wade

Build a Date Picker (uses popup calendar and TREATAS)


NEXT LEVEL Power BI Date Picker!

Wednesday, August 26, 2020

Power BI - How to Set a Default Slicer Value (8:49)

 https://www.youtube.com/watch?v=pCgK-Ze3nhA


Date example - add a DateRange calculated column with this DAX:


DateRange = IF(MONTH(Date[Date]) = MONTH(TODAY()) && YEAR(Date[Date]) = YEAR(TODAY()), "Current Month", MONTH(TODAY()) - MONTH(Date[Date]) & " Months ago")


Tuesday, August 25, 2020

Select Measure to Render Based on Rows

 

-- create a datatable to populate the rows of a matrix
Metric Slicer =
DATATABLE("Metric", STRING,
{
{ "Units" },
{ "Gross $" }
}
)


-- create a measure to return the correct measure based on the row in a matrix

Loan Metric Selector =
SWITCH(
SELECTEDVALUE(
'Metric Slicer'[Metric]
),
"Units", [Loans Closed Count],
"Gross $", [Total Loan Amount]
)

Total Quantity on Weekdays

 Total Quantity (Weekday) =

CALCULATE(
[Total Quantity],
FILTER(
'Internet Sales',
RELATED('Date'[DayNumberOfWeek]) > 1 &&
RELATED('Date'[DayNumberOfWeek]) < 7))


-- filter on the one side of the relationship
Total Quantity (Weekday) =
CALCULATE(
[Total Quantity],
FILTER(
'Date',
AND('Date'[DayNumberOfWeek] > 1,
'Date'[DayNumberOfWeek] < 7)))


7 Day Moving Average

 Sales 7-Day Moving Average =

VAR StartDate = DATEADD(LASTDATE('Date'[Date]), -6, DAY)
VAR EndDate = LASTDATE('Date'[Date])
 
RETURN
 
AVERAGEX(
DATESBETWEEN(
'Date'[Date],
StartDate,
EndDate),
[Total Sales])

Use CONCATENATEX for Debugging

 3 Month Sales Rolling Average (ConcatenateX) =

VAR EndDate = LASTDATE('Date'[Date])
 
RETURN
CALCULATE(
CONCATENATEX(
VALUES('Date'[MonthNumberOfYear]),
'Date'[MonthNumberOfYear], ", ", 'Date'[MonthNumberOfYear]),
DATESINPERIOD(
'Date'[Date],
EndDate,
-3,
MONTH))

Total Sales All Time (remove blanks)

 Total Sales (All Time) =

IF(
[Total Sales] = BLANK(),
BLANK(),
CALCULATE(
[Total Sales],
ALL('Date'[CalendarYear] ) ) )

3 Month Rolling Average

 3 Month Sales Rolling Average (Values) =

VAR EndDate = LASTDATE('Date'[Date])
 
RETURN
CALCULATE(
CONCATENATEX(
VALUES('Date'[MonthNumberOfYear]),
'Date'[MonthNumberOfYear], ", "), //[Total Sales]),
DATESINPERIOD(
'Date'[Date],
EndDate,
-3,
MONTH))

Rolling 12 Months Profit

 Rolling 12 Months Profit =

VAR StartDate = NEXTDAY(SAMEPERIODLASTYEAR(LASTDATE('Date'[Date])))
VAR EndDate = LASTDATE('Date'[Date])
 
RETURN
CALCULATE(
[Profit],
DATESBETWEEN(
'Date'[Date],
StartDate,
EndDate))

Create a table in DAX

 Metric Selector =

DATATABLE("Metric", STRING,
{
{ "Units" },
{ "Gross $" }
}
)