DAX
BOOKMARK
BUTTON-NAVIGATION
TOOLTIP
DrillDown
PARAMETER
RLS
function will be called in SP but sp will not called in Funciton[DML language is
not used]
DML Command is used in sp not in function.
New Column = When we need a calculation on every row in that case we use column and
it is static in nature.
New Measure = When we need aggregation, Eg- Percentage, Ratio, Aggregation etc
[Coding/Formula]
Measure is not static value its dynanamic in nature, will not add in the existing
table, is displayed in vizualization.
Type of Measures:-
Implicit- Readymade Measure. [Doing as it own, Basic Aggregation]
Explicit- For measure if we write the formala to get some derived result than it
called as Explicit measure
New Table
Text Function(left,right,mid,upper, lower, concatenate, trim, LEN, EXACT, FIND)
filter function
ALL[Remove all the filter], ALLSELECTED, ALLEXCEPT, FILTER
CALCULATE- Evaluate the expression and give you the single value in the modified
filter context,
CALULATE TABLE- evaluate a table expression in the modified filter context,
LOOKUPVALUES
SELECTEDVALUES
Earlier
REMOVEFILTER
EARLIEST,
INFORMATION FUNCTION
ISBLANK()
ISNUMBER()
ISTEXT()
CONTAINSSTRING()
CONTAINSSTRINGEXACT()
CONTAINROW()
NOT CONTAINROW()
IN and OR FUNCTIN()
ISFILTERED()
HASONEVALUE()
HASONEFILTER()
IFERROR()
ISERROR()
CONTAINS()
ISCROSSFILTERED()
Relationship Function
Crossfilter
Related
Relatedtable
Userelationship
Agregation function
Sum
SumX
Min
MinA
MinX
Max
MaxA
MaxX
Count
CountX
CountA
CountAX
Average
AverageA
AverageAX
CountBlank- help us to count the number of blank cell in particular column
DistinctCount
CountRows
DistinctCountNOBlank
PARENT AND CHILD FUNCTION
PATH
PATHCONTAINS
PATHITEM
PATHITEMREVERSE
PATHLENGH
MATH FUNCTION
INT()-Convert into integer and remove the deceimal place.
CURRENCY()- Convert into Money
ROUND()- It rounds the number to the given number of digits and if the deceimal
point is more than 5 than it round to next digit.
ROUNDUP()It will take the number in next level
ROUNDDOWN()
DIVIDE()
POWER()- power(2,2)
EVEN()- ROUND UP THE NUMBER TO THE NEXT EVEN NEAREST INGEGER
ODD()- ROUND UP THE NUMBER TO THE NEXT ODD NEAREST INGEGER
FACTORIAL() = fact(5) = 5*4*3*2*1
SIGN()= Sign(columnname)
SQRT()
RankX()
Region City = CONCATENATE(Orders[Region],Orders[City])
Region State City =
CONCATENATE(Orders[Region],CONCATENATE(Orders[State],Orders[City]))
Region State City = Orders[Region] & " - " & Orders[State] & " - " & Orders[City]
UCase Customer Name = UPPER(Orders[Customer Name])
LCase Customer Name = LOWER(Orders[Customer Name])
Country Code = LEFT(Data[Order ID],2)
year Code = MID(Data[Order ID],4,4)
Order Code = RIGHT(Data[Order ID],6)
Len Customer = LEN(Customer[Customer Name])
Find Text = FIND("-",Data[Order ID],1,0)
Find Space = FIND(" ",Customer[Customer Name],1,0)
First Name = LEFT(Customer[Customer Name],Customer[Find Space])
Last Name = RIGHT(Customer[Customer Name],Customer[Len Customer]-Customer[Find
Space])
Replace Val = REPLACE(Data[Order ID],4,4,"xxx")
Substitute Val = SUBSTITUTE(Data[Product ID],"-","/")
Rept Char = REPT("x",10)
FirstName = trim(LEFT(Orders[Customer Name],Orders[FindSpace]))
Date Functions
==============
GetDay = DAY(Data[Order Date])
GetMonth = MONTH(Data[Order Date])
Getyear = YEAR(Data[Order Date])
Get Date = DATE(Data[Getyear],Data[GetMonth],Data[GetDay])
GetDay = Orders[Order Date].[Day]
GetMonth = Orders[Order Date].[Month]
GetMonthNo = Orders[Order Date].[MonthNo]
GetYear2 = Orders[Order Date].[Year]
GetQtr = Orders[Order Date].[Quarter]
GetQtr2 = Orders[Order Date].[QuarterNo]
Date Diff = DATEDIFF(Orders[Order Date],Orders[Ship Date],DAY)
Date Add = DATEADD(Orders[Order Date],10,DAY)
get Today Date = today()
Get Time = now()
End of Month = EOMONTH(Orders[Order Date],0)
Get Weekday = WEEKDAY(Orders[Order Date])
Get Weeknum = WEEKNUM(Orders[Order Date])
Number Functions
=================
Func_Abs = ABS(Orders[Profit])
RoundSales = ROUND(Data[Profit],2)
RoundUpSales = ROUNDUP(Data[Profit],2)
RounddownSales = ROUNDDOWN(Data[Profit],2)
CeilingProfit = CEILING(Data[Profit],100)
FloorProfit = FLOOR(Data[Profit],100)
RoundEven = EVEN(Data[Profit])
RoundOdd = ODD(Data[Profit])
DivideNum = Data[Profit]/Data[Sales]
FunDivide = DIVIDE(Data[Profit],Data[Sales],0)
FunQuotient = QUOTIENT(Data[Profit],Data[Sales])
Func_Quoient = IFERROR(QUOTIENT(Orders[Sales],Orders[Profit]),0)
modFun = MOD(Data[Sales],2)
Func_Mod = IFERROR(MOD(Orders[Sales],10),0)
FunPower = POWER(Data[Sales],3)
FunSqrt = SQRT(Data[Sales])
Rand Num = RAND()
Randbetween Num = RANDBETWEEN(100,1000)
Information Formulas
=====================
Is Even = ISEVEN(Data[Profit])
Is odd = ISODD(Data[Profit])
Is Text = ISTEXT(Data[Profit])
Is NonText = ISNONTEXT(Data[Profit])
Is Number = ISNUMBER(Data[Profit])
Is Number = ISLOGICAL(Data[Profit])
FuncISError = ISERROR(Orders[Sales])
Measure
=========
SalesSUM = SUM('Data (2)'[Sales])
SalesAverage = AVERAGE('Data (2)'[Sales])
SalesCount = COUNT('Data (2)'[Sales])
SalesCountA = COUNTA('Data (2)'[Sales])
SalesCountBlanks = COUNTBLANK('Data (2)'[Sales])
SalesCountRows = COUNTROWS(Location)
SalesMax = MAX('Data (2)'[Sales])
SalesMin = MIN('Data (2)'[Sales])
GetUniqueCount = DISTINCTCOUNT(Location[State])
MS_ProfitShare = format(SUM(Orders[Profit])/SUM(Orders[Sales]),"0.0%")
CC_ProfitPercent = Orders[Profit]/Orders[Sales]
Measure
==========
Total Sales All = CALCULATE([Total Sales],ALL(Location[Region]))
Total Except = CALCULATE(SUM(Data[Sales]),ALLEXCEPT(Location,Location[Region]))
Total Sales AllExcept = CALCULATE(Customer[TOTAL
SALES],ALLEXCEPT(Location,Location[Region]))
Format - Date
========================
PreFormat Date = FORMAT(Orders[Order Date],"General Date")
PreFormat Date = FORMAT(Orders[Order Date],"Long Date")
PreFormat Date = FORMAT(Orders[Order Date],"Medium Date")
PreFormat Date = FORMAT(Orders[Order Date],"Short Date")
CusFormat Date = FORMAT(Orders[Order Date],"d")
CusFormat Date = FORMAT(Orders[Order Date],"dd")
CusFormat Date = FORMAT(Orders[Order Date],"ddd")
CusFormat Date = FORMAT(Orders[Order Date],"dddd")
CusFormat Date = FORMAT(Orders[Order Date],"m")
CusFormat Date = FORMAT(Orders[Order Date],"mm")
CusFormat Date = FORMAT(Orders[Order Date],"mmm")
CusFormat Date = FORMAT(Orders[Order Date],"mmmm")
CusFormat Date = FORMAT(Orders[Order Date],"yy")
CusFormat Date = FORMAT(Orders[Order Date],"yyyy")
CusFormat Date = FORMAT(Orders[Order Date],"dd mmmm yyyy, dddd")
Format Numbers
========================
PreFormat Num General = FORMAT(Orders[Sales],"General Number")
PreFormat Num Percent = FORMAT(Orders[Discount],"Percent")
PreFormat Num Standard = FORMAT(Orders[Sales], "Standard")
CustFormat Num = FORMAT(Orders[Discount],"0%")
CustFormat Num = FORMAT(Orders[Discount],"0.0%")
CustFormat Num = FORMAT(Orders[Sales],"0.0")
CustFormat Num = FORMAT(Orders[Sales],"0.00")
CustFormat Num = FORMAT(Orders[Sales],"#,##0.00")
CustFormat Num = FORMAT(Orders[Sales],"#,##0.00;(#,##0.00)")
CustFormat Num = FORMAT(Orders[Profit],"0.0%;(0.0%)")
Conditional Statements
===================================
if Condition = IF(DataBackup[Sales]>5000,"High","Low")
Nestedif Condition =
IF(DataBackup[Sales]>5000,"High",if(DataBackup[Sales]>2000,"Medium","Low"))
GetProdCode = IF(LEFT('Data (2)'[Product ID],3)="FUR","Furniture",IF(LEFT('Data
(2)'[Product ID],3)="OFF","Office","Technology"))
getWeekName = SWITCH(WEEKDAY('Data (2)'[Order Date]),
1,"Sunday",
2,"Monday",
3,"Tuesday",
4,"Wednesday",
5,"Thrusday",
6,"Friday",
7,"Saturday")
Related Columns
=========================
getCust = RELATED(Customer[Customer Name])
lookup col = LOOKUPVALUE(Customer[Customer Name],Customer[Customer ID],'Data
(2)'[Customer ID])
GetSegment = RELATED(Segment[Segment])
Columns
==============
Get Customer Name = LOOKUPVALUE(Customer[Customer Name],Customer[Customer
ID],Data[Customer ID])
Sales SUM = SUMX(Data,Data[Sales])-Done
Sales AVERAGE = AVERAGEX(Data,Data[Sales])-Done
Sales MIN = MINX(Data,Data[Sales])-Done
Sales MAX= MAXX(Data,Data[Sales])-Done
Sales COUNT = COUNTX(Data,Data[Sales])-Done
Sales PRODUCT = PRODUCTX(Data,Data[Sales])-Done
Sales SUM = SUMX(RELATEDTABLE(Data),Data[Sales])-Done
Sales AVERAGE = AVERAGEX(RELATEDTABLE(Data),Data[Sales])-Done
Sales MIN = MINX(RELATEDTABLE(Data),Data[Sales])-Done
Sales MAX= MAXX(RELATEDTABLE(Data),Data[Sales])-Done
Sales COUNT = COUNTX(RELATEDTABLE(Data),Data[Sales])-Done
Sales PRODUCT = PRODUCTX(RELATEDTABLE(Data),Data[Sales])-Done
Ship Mode = CONCATENATEX(RELATEDTABLE(ShipMode),ShipMode[Ship
Mode],",",ShipMode[Ship Mode],ASC)
Calculate Table = SUMX(CALCULATETABLE(Location,Location[Region] = "East"),[Total
Sales])
Calculate Table2 = SUMX(CALCULATETABLE(Location,Location[Region]
In{"East","South"}), [Total Sales])
Get Total Sales East = SUMX(CALCULATETABLE(Location,Location[Region] =
"East"),SUMx(RELATEDTABLE(Data),Data[Sales]))
Table
========
Filter5000 = FILTER(Data,Data[Sales]>5000)
TopN Data = TOPN(100,Data,Data[Sales],DESC)
Summarize Table = SUMMARIZE(Data,Location[LOC_ID],Data[Sales])
SummarizeColumns Table = SUMMARIZECOLUMNS(Location[Region],"Total
Sales",SUM(Data[Sales]),"Total Profit",SUM(Data[Profit]))
DistinctTable = DISTINCT(Location[Region])
New Segment Table = ADDCOLUMNS(Segment,"Total Sales", [Total Sales])
Calendar Table = CALENDAR(DATE(2020,1,1),TODAY())- DONE //DISPLAY THE SERIES OF
DATE MENTION IN FUNCTION[STARTDATE AND END DATE]
CALENDER AUTO = CALENDARAUTO(1)- // AUTOMATICALLY DISPLAY THE SERIES OF DATE -
HAVING IN THE DATASET
DATES BETWEEN = DATESBETWEEN(Data[Order Date],date(2016,1,1),date(2017,12,31))
//DISPLAY ALL THE DATES OF ORDER DATE COLUMN IN DATA TABLE BETWEEN THE START DATE
AND END DATE
DATES INPERIOD = DATESINPERIOD(Data[Order Date],DATE(2017,1,1),5,MONTH) // DISPLAY
THE DATES OF ORDER DATE COLUMN IN DATA TABLE FOR PARTICULAR PERIOD MENTION IN
FUNCTION
DATES MTD = DATESMTD(Data[Order Date])//DISPLAY LATEST MONTH DATA
DATES QTD = DATESQTD(Data[Order Date])//DISPLAY LATEST QUATOR DATA
DATES YTD = DATESYTD(Data[Order Date])// DISPLAY LATEST YEAR DATA
END OF MONTH = ENDOFMONTH(Data[Order Date])//RETURN THE LAST DATE OF THE LATEST
MONTH
END OF QUARTER= ENDOFQUARTER(Data[Order Date])//RETURN THE LAST DATE OF THE
CURRENT/LATEST QUARTER
END OF YEAR = ENDOFYEAR(Data[Order Date])//RETURN THE LAST DATE OF THE LATEST YEAR
Variables
=============================================
VAR WholeNumberA = 3
VAR WholeNumberB = 2
RETURN DIVIDE( WholeNumberA, WholeNumberB)
My Measure =
VAR textVar1 = "Hello "
VAR textVar2 = "World"
RETURN CONCATENATE(textVar1,textVar2)
Sales Text =
VAR SalesQty = SUM('Data'[Quantity])
VAR Text1 = "This month we sold "
VAR Text2 = " Items"
VAR Result = IF(SalesQty > 0,Text1 & SalesQty & Text2,"No sales this month")
RETURN Result
Greeting =
VAR CurrentHour = HOUR(NOW())
VAR GreetingText =
SWITCH(TRUE(),CurrentHour<12,"Morning",CurrentHour<17,"Afternoon","Evening")
RETURN "Good " & GreetingText & ", " & Customername()
City and Country =
VAR city = 'Location'[City]
VAR country = 'Location'[Country]
RETURN city & ", " & country
Reg State City =
Var Reg = Location[Region]
Var State = Location[State]
Var City = Location[City]
Return Reg & " " & State & " " & City
Total Sales > $100 =
VAR SalesAbove100 =
FILTER('Fact Sale','Fact Sale'[Total Including Tax]>=100)
RETURN COUNTROWS(SalesAbove100)
TotalRows =
Var Salesbelow500 = FILTER(data,Data[Sales]<500)
Return COUNTROWS(Salesbelow500)
Some Important SQL Query
SELECT MAX(SALARY) FROM Employee WHERE SALARY < (SELECT MAX(SALARY) FROM
Employee);// give 2nd hightest salary
select * from empsalary order by salary desc limit 1,1; // 2nd Higesht Salary
select *, max(salary) from empsalary where salary < (select max(salary) from
empsalary); // 2nd Higesht Salary
select top 1 salary from (select top2 salary from student order by salary desc)
abc order by salary asc;
select * from empsalary order by salary desc limit 2,1; // 3rd higest Salary
select * , count(id)
from empsalary group by id having count(id)
> 1; //Duplicate Record
select * from empsalary where mod(id,2) =0; //Even record
select * from empsalary where mod(id,2) !=0; //odd record
create table emp10 as select * from empsalary; //Copy table with information
o create table emp11 as select * from empsalary where 5 = 6; //copy only structure
select * from empsalary e1, empsalary e2 where e1.country = e2.country and e1.id !
= e2.id; // Retrive all the empname having same country
select * , max(salary) from empsalary group by country; //Highest value from each
country
Select Emp_no,E_name,D_name,Loc from Employee left outer Join Department on
(Employee.Dept_no = Department.Dept_no)
\
What are ‘Measures’ in Power BI? How can we create them?
What do you understand by the Power BI Gateway?
What is Bidirectional cross-filtering in Power BI?
Which table functions will you use to group data in Power BI?
What are query parameters? What are Power BI Templates?
How many active relationships can we have between two tables in Power Pivot data
model?
Tell us about “Query folding” in Power Query
What do you know about the transformation in Power Query Editor?
Ans. The Power Query Editor enables us to import data from multiple sources and
transform it in many ways as per our requirements. Some general data transformation
practices in Power Query Editor are:
Change data types of columns.
Rename columns.
Replace values.
Fix errors in Any Column group.
Working with the nested data in Structured Column groups.
Add custom columns, conditional columns, add measures, etc.
What do you know about the Power Map?
What are the different types of data refreshes in Power BI?
In Power BI, data of published reports can be refreshed in four ways; Package
refresh, Model refresh, Tile refresh, and Visual container refresh.
Package refresh – The package refresh will refresh the report by updating the data
from SharePoint Online or OneDrive. Package refreshing does not refresh data from
the source but from its cloud location.
Model or Data refresh – This type of refreshing refreshes data in a report from its
original data source. Model or data refresh is done within the Power BI Service
with the help of gateway permission for on-premises data sources. This method uses
Refresh now, or Schedule refresh options.
Tile refresh – Tile refresh refreshes the cache data of all the tiles on a
dashboard. It occurs in every 15 minutes automatically. If it does not happen, we
can select the Refresh dashboard tiles option from the ellipses(…) icon on the
dashboard.
Visual container refresh – This refresh refreshes the cache of all the visuals
containers of a Power BI report.
What is an Advanced editor in Power BI?
Ans. An Advanced Editor is an editor within the Power Query Editor. It is used to
view the M-code for any query. The Advanced Editor is generally used to check the
syntax of a query that will be run in the editor.
We can access the Advanced Editor from the Home or View tab in Power Query Editor.
We can select a query from the list of queries and work with it in the Advanced
editor window and analyze the code step by step.
Can we use Power BI on mobile devices?
Ans. Yes, we can use Power BI on mobile devices. Power BI has mobile compatible
apps for Android devices, iOS devices, and Windows 10 devices. We can download the
Power BI app for a preferred device from app stores such as Google Play, Microsoft
Store or Apple App Store.
What is Bookmark?
Bookmark in Power BI helps you to capture the configured view of a report page in a
specific time. This includes filter and state of visual which can use a short cut
to come back to the report that you can add as a bookmark.
How to handle Many to Many relationships in Power BI?
You can use Crossfiltering option in Power BI to address the Many to Many
relationships.
State the major differences between MAX and MAXA functions
If you want to calculate numeric values, then use MAX. However, if it is for non
numeric values, then you should use MAXA.