Forum Discussion
Column level difference between two selected dates (ie. Max date - Min date)
- Anonymous3 years ago
Hi stanleycj
You can refer to the following example.
1.Create a table
Type = SUMMARIZE(Detail_Tbl,[BNK])Then put it into a slicer
2.Create a new calculated column in date table
Month = IF([MthYr]="Mvt.",0,MONTH([MIS_Date]))3.Then create three measure
Measure 1 = var a=FILTER(ALLSELECTED(Date_Tbl),[Month]<>0) var b=SELECTCOLUMNS(ALL(Detail_Tbl),"a",MONTH(Detail_Tbl[MthYr])) var c=FILTER(Detail_Tbl,[BNK] in VALUES('Type'[BNK])&&[ST]=1) return IF(SELECTEDVALUE(Date_Tbl[MthYr])="Mvt.",CALCULATE(SUM(Detail_Tbl[VAL]),FILTER(c,MONTH([MthYr])=MINX(a,[Month])))-CALCULATE(SUM(Detail_Tbl[VAL]),FILTER(c,MONTH([MthYr])=MAXX(a,[Month]))),IF(OR(SELECTEDVALUE(Date_Tbl[Month])=MINX(a,[Month]),SELECTEDVALUE(Date_Tbl[Month])=MAXX(a,[Month]))&&SELECTEDVALUE(Date_Tbl[Month]) in b,CALCULATE(SUM(Detail_Tbl[VAL]),FILTER(c,MONTH([MthYr])=SELECTEDVALUE(Date_Tbl[Month]))))) Measure 2 = var a=FILTER(ALLSELECTED(Date_Tbl),[Month]<>0) var b=SELECTCOLUMNS(ALL(Detail_Tbl),"a",MONTH(Detail_Tbl[MthYr])) var c=FILTER(Detail_Tbl,[BNK] in VALUES('Type'[BNK])&&[ST]=2) return IF(SELECTEDVALUE(Date_Tbl[MthYr])="Mvt.",CALCULATE(SUM(Detail_Tbl[VAL]),FILTER(c,MONTH([MthYr])=MINX(a,[Month])))-CALCULATE(SUM(Detail_Tbl[VAL]),FILTER(c,MONTH([MthYr])=MAXX(a,[Month]))),IF(OR(SELECTEDVALUE(Date_Tbl[Month])=MINX(a,[Month]),SELECTEDVALUE(Date_Tbl[Month])=MAXX(a,[Month]))&&SELECTEDVALUE(Date_Tbl[Month]) in b,CALCULATE(SUM(Detail_Tbl[VAL]),FILTER(c,MONTH([MthYr])=SELECTEDVALUE(Date_Tbl[Month]))))) Total = [Measure 1]+[Measure 2]Output
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Anonymous3 years ago
Hi stanleycj
I placed the type column in the column, and if you want to show b1, b2 can drill down
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more
Hi stanleycj
I placed the type column in the column, and if you want to show b1, b2 can drill down
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more
Hi @v-xinruzhu-msft ,
A small concern on the exisitng code, when we select Jan 23 and Jan 22. It doesn't work, since we are using month(), I tried to use with longdate "20230131" and index but i am facing a challenge. Could you pls suggest me.
Regards,
Stanley