cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Rksudhuman
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

 

Production.PNG

1 ACCEPTED SOLUTION

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

View solution in original post

2 REPLIES 2
Greg_Deckler
Super User
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...


@ me in replies or I'll lose your thread!!!
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Learn Power BI 2nd Edition

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

Helpful resources

Announcements
August 1 episode 9_no_dates 768x460.jpg

The Power BI Community Show

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

Power BI Dev Camp Session 24 without aka link and time 768x460.jpg

Ted's Dev Camp - July 28, 2022

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

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Top Solution Authors
Top Kudoed Authors