cancel
Showing results for
Did you mean:
Frequent Visitor

## POWER BI - Compare two days ,quarter,monthly production data

Hello Community,

I am new in BI , I want to create DAX funcation for compare yesterday quantity and day before yesterday quantity

My Filter is (i want dax formula for this concept )

Day in Number

1                     --- if i choose 1 then system show yesterday and daybefore yesterday data
2                      --- if i choose 2 then system show last two days and pervious two days data
7                     --- if i choose 7 then system show last week and last to last week data
15                   --- if i choose 15 then system show last 15 days and last month 15 days data
31                    --- if i choose 31 then system show last 31 days and last month days data

X axis is factory wise

Sample report like below

1 ACCEPTED SOLUTION
Frequent Visitor

Dear

Thanks for your support, i written my way please find the script

Pervious =
VAR ONe =
IF (
CONTAINS ( NumberDate; NumberDate[Selection]; "1" ) = TRUE ();
CALCULATE(SUM(gpcc_prod_day_analy_rpt_bi[QTY])
;FILTER(gpcc_prod_day_analy_rpt_bi
;gpcc_prod_day_analy_rpt_bi[Proddt]=TODAY()-6));
FALSE()
)
VAR Two =
IF (
CONTAINS ( NumberDate;NumberDate[Selection]; "2" ) = TRUE ();
CALCULATE(SUM(gpcc_prod_day_analy_rpt_bi[QTY])
;FILTER(gpcc_prod_day_analy_rpt_bi
;gpcc_prod_day_analy_rpt_bi[Proddt]<=TODAY()-7 &&
gpcc_prod_day_analy_rpt_bi[Proddt]>=TODAY()-8));
FALSE()
)

var Three=
IF (
CONTAINS ( NumberDate;NumberDate[Selection]; "7" ) = TRUE ();
CALCULATE(SUM(gpcc_prod_day_analy_rpt_bi[QTY])
;FILTER(gpcc_prod_day_analy_rpt_bi
;gpcc_prod_day_analy_rpt_bi[Proddt]<=TODAY()-12 &&
gpcc_prod_day_analy_rpt_bi[Proddt]>=TODAY()-19));
FALSE()
)
var Four=
IF (
CONTAINS ( NumberDate;NumberDate[Selection]; "15" ) = TRUE ();
CALCULATE(SUM(gpcc_prod_day_analy_rpt_bi[QTY])
;FILTER(gpcc_prod_day_analy_rpt_bi
;gpcc_prod_day_analy_rpt_bi[Proddt]<=TODAY()-21 &&
gpcc_prod_day_analy_rpt_bi[Proddt]>=TODAY()-31));
FALSE()
)
var Five=
IF (
CONTAINS ( NumberDate;NumberDate[Selection]; "31" ) = TRUE ();
CALCULATE(SUM(gpcc_prod_day_analy_rpt_bi[QTY])
;FILTER(gpcc_prod_day_analy_rpt_bi
;gpcc_prod_day_analy_rpt_bi[Proddt]<=TODAY()-32 &&
gpcc_prod_day_analy_rpt_bi[Proddt]>=TODAY()-61));
FALSE()
)

RETURN
ONe+Two+Three+Four+Five
2 REPLIES 2
Super User

See if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...

Become an expert!: Enterprise DNA
External Tools: MSHGQM
Latest book!:
Learn Power BI 2nd Edition
Frequent Visitor

Dear

Thanks for your support, i written my way please find the script

Pervious =
VAR ONe =
IF (
CONTAINS ( NumberDate; NumberDate[Selection]; "1" ) = TRUE ();
CALCULATE(SUM(gpcc_prod_day_analy_rpt_bi[QTY])
;FILTER(gpcc_prod_day_analy_rpt_bi
;gpcc_prod_day_analy_rpt_bi[Proddt]=TODAY()-6));
FALSE()
)
VAR Two =
IF (
CONTAINS ( NumberDate;NumberDate[Selection]; "2" ) = TRUE ();
CALCULATE(SUM(gpcc_prod_day_analy_rpt_bi[QTY])
;FILTER(gpcc_prod_day_analy_rpt_bi
;gpcc_prod_day_analy_rpt_bi[Proddt]<=TODAY()-7 &&
gpcc_prod_day_analy_rpt_bi[Proddt]>=TODAY()-8));
FALSE()
)

var Three=
IF (
CONTAINS ( NumberDate;NumberDate[Selection]; "7" ) = TRUE ();
CALCULATE(SUM(gpcc_prod_day_analy_rpt_bi[QTY])
;FILTER(gpcc_prod_day_analy_rpt_bi
;gpcc_prod_day_analy_rpt_bi[Proddt]<=TODAY()-12 &&
gpcc_prod_day_analy_rpt_bi[Proddt]>=TODAY()-19));
FALSE()
)
var Four=
IF (
CONTAINS ( NumberDate;NumberDate[Selection]; "15" ) = TRUE ();
CALCULATE(SUM(gpcc_prod_day_analy_rpt_bi[QTY])
;FILTER(gpcc_prod_day_analy_rpt_bi
;gpcc_prod_day_analy_rpt_bi[Proddt]<=TODAY()-21 &&
gpcc_prod_day_analy_rpt_bi[Proddt]>=TODAY()-31));
FALSE()
)
var Five=
IF (
CONTAINS ( NumberDate;NumberDate[Selection]; "31" ) = TRUE ();
CALCULATE(SUM(gpcc_prod_day_analy_rpt_bi[QTY])
;FILTER(gpcc_prod_day_analy_rpt_bi
;gpcc_prod_day_analy_rpt_bi[Proddt]<=TODAY()-32 &&
gpcc_prod_day_analy_rpt_bi[Proddt]>=TODAY()-61));
FALSE()
)

RETURN
ONe+Two+Three+Four+Five

Announcements

#### The Power BI Community Show

Watch the playback when Priya Sathy and Charles Webb discuss Datamarts! Kelly also shares Power BI Community updates.

#### Ted's Dev Camp - July 28, 2022

Watch Session 24 of Ted's Dev Camp along with past sessions!