DAX Functions
DAX Functions
DAX Functions
BOOKMARK
BUTTON-NAVIGATION
TOOLTIP
DrillDown
PARAMETER
RLS
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
filter function
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
MATH FUNCTION
Region State City = Orders[Region] & " - " & Orders[State] & " - " & Orders[City]
Date Functions
==============
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])
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")
Format Numbers
========================
PreFormat Num General = FORMAT(Orders[Sales],"General Number")
PreFormat Num Percent = FORMAT(Orders[Discount],"Percent")
PreFormat Num Standard = FORMAT(Orders[Sales], "Standard")
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"))
Related Columns
=========================
getCust = RELATED(Customer[Customer Name])
GetSegment = RELATED(Segment[Segment])
Columns
==============
Get Customer Name = LOOKUPVALUE(Customer[Customer Name],Customer[Customer
ID],Data[Customer ID])
Table
========
Filter5000 = FILTER(Data,Data[Sales]>5000)
DistinctTable = DISTINCT(Location[Region])
New Segment Table = ADDCOLUMNS(Segment,"Total Sales", [Total Sales])
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()
TotalRows =
Var Salesbelow500 = FILTER(data,Data[Sales]<500)
Return COUNTROWS(Salesbelow500)
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
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
Which table functions will you use to group data in Power BI?
How many active relationships can we have between two tables in Power Pivot data
model?
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:
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.
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.
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.
You can use Crossfiltering option in Power BI to address the Many to Many
relationships.
If you want to calculate numeric values, then use MAX. However, if it is for non
numeric values, then you should use MAXA.