QN1: Find out No of Employees belongs to Analyst Department
Method -1
Count of Employees = calculate(count(Employee[Department]), Filter(‘Employee’,
Employee[Department]=”Analyst Department”))
Method -2
Count of Employees = calculate(countx(Employee, Employee [Department]), Filter(‘Employee’,
Employee[Department]=”Analyst Department”))
QN2: Create a table with Two columns Department name and avg Sal
Method -1
= SUMMARIZECOLUMNS(Employee[DepartmentName], Employee[AvgSal])
QN3: Need a count of Employees whose salary is greater than average salary of department of Analyst
Method -1
countofEmployees=calculate(count(Employee[Empid]),Filter(Employee[Department]=”Analyst”),Filter(Employe
e[Sal]>Average(Employee[Sal])))
Method -2
countofEmployees=calculate(countx(Employee, Employee
[Empid]),Filter(Employee[Department]=”Analyst”),Filter(Employee[Sal]>Average(Employee[Sal])))
QNO 5: Difference between Sum And Sumx
Sum and sumx will be performing on aggregation operations the both the functions will allows the filters also
but in SumX we can write a aggregations on expressions like
Netamount = SUMX(ALL(Data),Data[SalesAmount]-Data[TaxAmt])
QN: YOY And MOM
YOY:
totalSales= sum(Tablename[Sales])
PreviousYs= calculate(sum(tablename[Sales]),previousyear(tablename[Sales]))
YOY= (Totalsales-PreviousYS)/[PreviousYS]
MOM:
totalSales= sum(Tablename[Sales])
PreviousMs= calculate(sum(tablename[Sales]),previousMonth(tablename[Sales]))
MOM= (Totalsales-PreviousMS)/[PreviousMS]
QN: What are the ways to delete duplicate rows
1. By Distinct operatore
2. By using Row_number() with the CTE
QN: what is CTE? And it’s difference between cte and temp table?
CTE:
CTE (Common Table expression) can be thought of as a temporary result set that is defined within the
execution scope of a single select, insert, update,delete or createview statement.
Cte can be self-referencing and can be referenced multiple times in the same query.
Cte we can use with in the query itself.
Temp table:
Temp table also used for to store the result of query on temporary basis. But we can able to use with in
the current session it is defined by #
QN: Differenct connectivity modes? Can we create measures in Direct mode and live connection?
3 types of modes we have
1. Import Mode
2. Direct Mode
3. Live Connection
Yes we can create the measures in Direct mode and live connection
QN: Difference ways to share the report?
Mainly we have 3 types:
App.Power BI .com
Content Pack.
Reporting Server
Additionally we have below methods:
1. Publish to Web
2. Embed in Web
3. Embeded in sharepoint online
4. Export to Excel
5. Export to Template
QN: Different types of roles what kind of roles we can provide?
We have a manage roles option, under this option we can create two type of roles
Dynamic roles and Statistical roles
In workspace majorly we will use Statistical roles
QN: Selected measure with Dynamically
Selectedmfeasure = SWITCH(true,
SELECTEDVALUE(Data[Color])="Black",FORMAT(SUM(Data[SalesAmount]),"0"),
SELECTEDVALUE(Data[Color])="Multi",FORMAT(SUM(Data[SalesAmount]),"0"),
SELECTEDVALUE(Data[Color])="Red",FORMAT(SUM(Data[SalesAmount]),"0"),
selectedvalue(Data[Color])="Silver",FORMAT(SUM(Data[SalesAmount]),"0"),
SELECTEDVALUE(Data[Color])="Balnk",FORMAT(SUM(Data[SalesAmount]),"0"))
QN: we need to create two columns based on existing column firstname.lastname@gmail.com like
firstname and lastname
For Firstname:
Left(Text, Search(Findtext, withintext,Startposition, Notfoundvalue)
Example:
Left(firstname.lastname@gmail.com ,Search(“.”,firstname.lastname@gmail.com ,1,0)-1)
Result: firstname
Mid:
MID(Sheet1[Column1],SEARCH(".",Sheet1[Column1])+1,FIND("@",Sheet1[Column1])-
SEARCH(".",Sheet1[Column1])-1)
QNO:find out who r the users visited more than once in the below table
with cte
as(
select distinct orderid,customerid from orders
)
select customerid, count(*) from CTE
group by customerid
having count(*)>1
Method2: select customerid, count(*) from(
select distinct orderid,customerid from orders
) Orders
group by customerid
having count(*)>1
QNO: Top 5 cities Sales amount has to display
Sum = Sum(Salesamount)
Rankx = Rankx( All (Data[city]),[ Sum], , Dsc, Skip)
IF(ISFILTERED(Data[City]),IF([Rankx]<=5, [Sum],
BLANK()),CALCULATE([Sum],TOPN(5,VALUES(Data[City]),[Sum])))
1. TotalMTD:
2. TotalYTD
3. SameperiodLastyear
4. If:
Checks if a condition provided as the first argument is met. Returns one value if the condition is TRUE, and
returns another value if the condition is FALSE.
5. Sign:
Returns the sign of a number: 1 if the number is positive, zero if the number is zero, or -1 if the number is
negative.
6.Replace:
REPLACE replaces part of a text string, based on the number of characters you specify, with a different text
string.
Syntax:
REPLACE(Sheet1[Column1],1,2,"vasu")
7 convert:
Converts an expression of one data type to another.
Syntax:
CONVERT(<Expression>, <Datatype>)
convert = CONVERT(DATE(2020,3,2),integer)8. Datediff
9. Timevalue:
Converts a time in text formate to a time in date time formate.
Time value(Text time)
convert = CONVERT(DATE(2020,3,2),integer)
10. WeekDay:
11. DatesBetween
12. DatesinPeriod
13. firstnonblank
14. parallelperiod
15. sameperiodlastyear
16. TotalQTD
17. allexcept:
18. calculate
19. distinct
20. crossfilter
21. related
22. userelationship
23. contains
24. iserror
25. islogical
26. Naturalinnerjoin
27.Naturalleftjoin
28.Union
29. pathcontains
30. PAthitem
31.crossjoin
32. distinctcount
33. concatenate
34. concatenatex
35. find
36. search
37. lookup
38.lookupvalue
39.and
40.iferror
41.switch
42. ceiling
43.divide
44. sum
45. sumx
46. except
47. search
48. substitute
49. count
50. distinctcount
51. countblank
53.CountAX
Findout the Aging and bucketing
Agingcountoforders =
CALCULATE(COUNTROWS(Orders),
FILTER(Orders,
COUNTROWS(FILTER(Aging,DATEDIFF(Orders[Order Date],TODAY(),DAY)>= Aging[Min]&&
DATEDIFF(Orders[Order Date],TODAY(),DAY)<=Aging[Max]))>0))
How findout current year sales and previous year sales dynamically
Current YearSales = CALCULATE(SUM(Orders[Sales]),YEAR(dimdate[Date])=YEAR(TODAY()) )
Previous YearSales = CALCULATE(SUM(Orders[Sales]),YEAR(dimdate[Date])=YEAR(TODAY()) -1)
How to Findout the TopN + others salary
rankswise = CALCULATE(SUM(Orders[Sales]),
FILTER(VALUES(Orders[Customer Name]),
COUNTROWS(FILTER('Grouping',[Rankx]>'Grouping'[Min] && [Rankx]<='Grouping'[Max]))>0))
(Or)
rankswise = CALCULATE(SUM(Orders[Sales]),
FILTER(VALUES(Orders[Customer Name]),
COUNTROWS(FILTER('Grouping',RANKX(ALL(Orders[CustomerName]),[TotalSales],,DESC)>='Grouping'[Min]
&& RANKX(ALL(Orders[Customer Name]),[TotalSales],,DESC)<='Grouping'[Max]))>0))
By Using Var calculating Forecast reports:
Dax queries.pdf

Dax queries.pdf

  • 1.
    QN1: Find outNo of Employees belongs to Analyst Department Method -1 Count of Employees = calculate(count(Employee[Department]), Filter(‘Employee’, Employee[Department]=”Analyst Department”)) Method -2 Count of Employees = calculate(countx(Employee, Employee [Department]), Filter(‘Employee’, Employee[Department]=”Analyst Department”)) QN2: Create a table with Two columns Department name and avg Sal Method -1 = SUMMARIZECOLUMNS(Employee[DepartmentName], Employee[AvgSal]) QN3: Need a count of Employees whose salary is greater than average salary of department of Analyst Method -1 countofEmployees=calculate(count(Employee[Empid]),Filter(Employee[Department]=”Analyst”),Filter(Employe e[Sal]>Average(Employee[Sal]))) Method -2 countofEmployees=calculate(countx(Employee, Employee [Empid]),Filter(Employee[Department]=”Analyst”),Filter(Employee[Sal]>Average(Employee[Sal]))) QNO 5: Difference between Sum And Sumx Sum and sumx will be performing on aggregation operations the both the functions will allows the filters also but in SumX we can write a aggregations on expressions like Netamount = SUMX(ALL(Data),Data[SalesAmount]-Data[TaxAmt])
  • 2.
    QN: YOY AndMOM YOY: totalSales= sum(Tablename[Sales]) PreviousYs= calculate(sum(tablename[Sales]),previousyear(tablename[Sales])) YOY= (Totalsales-PreviousYS)/[PreviousYS] MOM: totalSales= sum(Tablename[Sales]) PreviousMs= calculate(sum(tablename[Sales]),previousMonth(tablename[Sales])) MOM= (Totalsales-PreviousMS)/[PreviousMS] QN: What are the ways to delete duplicate rows 1. By Distinct operatore 2. By using Row_number() with the CTE QN: what is CTE? And it’s difference between cte and temp table? CTE: CTE (Common Table expression) can be thought of as a temporary result set that is defined within the execution scope of a single select, insert, update,delete or createview statement. Cte can be self-referencing and can be referenced multiple times in the same query. Cte we can use with in the query itself. Temp table: Temp table also used for to store the result of query on temporary basis. But we can able to use with in the current session it is defined by # QN: Differenct connectivity modes? Can we create measures in Direct mode and live connection? 3 types of modes we have 1. Import Mode 2. Direct Mode 3. Live Connection Yes we can create the measures in Direct mode and live connection
  • 3.
    QN: Difference waysto share the report? Mainly we have 3 types: App.Power BI .com Content Pack. Reporting Server Additionally we have below methods: 1. Publish to Web 2. Embed in Web 3. Embeded in sharepoint online 4. Export to Excel 5. Export to Template QN: Different types of roles what kind of roles we can provide? We have a manage roles option, under this option we can create two type of roles Dynamic roles and Statistical roles In workspace majorly we will use Statistical roles QN: Selected measure with Dynamically Selectedmfeasure = SWITCH(true, SELECTEDVALUE(Data[Color])="Black",FORMAT(SUM(Data[SalesAmount]),"0"), SELECTEDVALUE(Data[Color])="Multi",FORMAT(SUM(Data[SalesAmount]),"0"), SELECTEDVALUE(Data[Color])="Red",FORMAT(SUM(Data[SalesAmount]),"0"), selectedvalue(Data[Color])="Silver",FORMAT(SUM(Data[SalesAmount]),"0"), SELECTEDVALUE(Data[Color])="Balnk",FORMAT(SUM(Data[SalesAmount]),"0")) QN: we need to create two columns based on existing column firstname.lastname@gmail.com like firstname and lastname For Firstname: Left(Text, Search(Findtext, withintext,Startposition, Notfoundvalue) Example: Left(firstname.lastname@gmail.com ,Search(“.”,firstname.lastname@gmail.com ,1,0)-1) Result: firstname
  • 4.
    Mid: MID(Sheet1[Column1],SEARCH(".",Sheet1[Column1])+1,FIND("@",Sheet1[Column1])- SEARCH(".",Sheet1[Column1])-1) QNO:find out whor the users visited more than once in the below table with cte as( select distinct orderid,customerid from orders ) select customerid, count(*) from CTE group by customerid having count(*)>1 Method2: select customerid, count(*) from( select distinct orderid,customerid from orders ) Orders group by customerid having count(*)>1 QNO: Top 5 cities Sales amount has to display Sum = Sum(Salesamount) Rankx = Rankx( All (Data[city]),[ Sum], , Dsc, Skip) IF(ISFILTERED(Data[City]),IF([Rankx]<=5, [Sum], BLANK()),CALCULATE([Sum],TOPN(5,VALUES(Data[City]),[Sum]))) 1. TotalMTD: 2. TotalYTD 3. SameperiodLastyear
  • 5.
    4. If: Checks ifa condition provided as the first argument is met. Returns one value if the condition is TRUE, and returns another value if the condition is FALSE. 5. Sign: Returns the sign of a number: 1 if the number is positive, zero if the number is zero, or -1 if the number is negative. 6.Replace: REPLACE replaces part of a text string, based on the number of characters you specify, with a different text string. Syntax: REPLACE(Sheet1[Column1],1,2,"vasu") 7 convert: Converts an expression of one data type to another. Syntax: CONVERT(<Expression>, <Datatype>) convert = CONVERT(DATE(2020,3,2),integer)8. Datediff 9. Timevalue: Converts a time in text formate to a time in date time formate. Time value(Text time) convert = CONVERT(DATE(2020,3,2),integer) 10. WeekDay: 11. DatesBetween 12. DatesinPeriod 13. firstnonblank 14. parallelperiod 15. sameperiodlastyear 16. TotalQTD
  • 6.
    17. allexcept: 18. calculate 19.distinct 20. crossfilter 21. related 22. userelationship 23. contains 24. iserror 25. islogical 26. Naturalinnerjoin 27.Naturalleftjoin 28.Union 29. pathcontains 30. PAthitem 31.crossjoin 32. distinctcount 33. concatenate 34. concatenatex 35. find 36. search 37. lookup 38.lookupvalue 39.and 40.iferror 41.switch
  • 7.
    42. ceiling 43.divide 44. sum 45.sumx 46. except 47. search 48. substitute 49. count 50. distinctcount 51. countblank 53.CountAX Findout the Aging and bucketing Agingcountoforders = CALCULATE(COUNTROWS(Orders), FILTER(Orders, COUNTROWS(FILTER(Aging,DATEDIFF(Orders[Order Date],TODAY(),DAY)>= Aging[Min]&& DATEDIFF(Orders[Order Date],TODAY(),DAY)<=Aging[Max]))>0)) How findout current year sales and previous year sales dynamically Current YearSales = CALCULATE(SUM(Orders[Sales]),YEAR(dimdate[Date])=YEAR(TODAY()) ) Previous YearSales = CALCULATE(SUM(Orders[Sales]),YEAR(dimdate[Date])=YEAR(TODAY()) -1) How to Findout the TopN + others salary rankswise = CALCULATE(SUM(Orders[Sales]), FILTER(VALUES(Orders[Customer Name]), COUNTROWS(FILTER('Grouping',[Rankx]>'Grouping'[Min] && [Rankx]<='Grouping'[Max]))>0))
  • 8.
    (Or) rankswise = CALCULATE(SUM(Orders[Sales]), FILTER(VALUES(Orders[CustomerName]), COUNTROWS(FILTER('Grouping',RANKX(ALL(Orders[CustomerName]),[TotalSales],,DESC)>='Grouping'[Min] && RANKX(ALL(Orders[Customer Name]),[TotalSales],,DESC)<='Grouping'[Max]))>0)) By Using Var calculating Forecast reports: