cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
kuldeepjain
Frequent Visitor

Reduce the Number of DAX

First DAX

LTFail-WC = VAR NumOfMonths = 12 
VAR ProductFamily = "WHOLE CURRENT"
VAR LTFailCutoff = LOOKUPVALUE(
    FailureData_ICF_Trend[ProductMaster.CutOffWarrenty],
    FailureData_ICF_Trend[ProductMaster.prod221],ProductFamily
                              )
VAR LastCurrentDate =EOMONTH(
    MAX (FailureData_ICF_Trend[repairmonth]),0)
VAR Period =
    DATESINPERIOD ( 'Calender'[Date], LastCurrentDate, - NumOfMonths, MONTH )
VAR Result = 
    CALCULATE (
      SUMX(
        VALUES ('Calender'[Date]), FailureData_ICF_Trend[FailQty_Trend]),Period, 
                FailureData_ICF_Trend[ProductMaster.prod221]= ProductFamily,
                FailureData_ICF_Trend[invoicemonth] >= LTFailCutoff 
              )
VAR FirstDateInPeriod = MINX ( Period, 'Calender'[Date] )
VAR LastDateWithSales = EOMONTH(MAX ( FailureData_ICF_Trend[repairmonth] ),0)
RETURN
    IF ( FirstDateInPeriod <= LastDateWithSales, Result )

 

Second DAX 

LTShipment-WC = 
VAR ProductFamily = "WHOLE CURRENT"
VAR NumOfMonths = LOOKUPVALUE(ShipmentData_ICF_T[ProductMaster.Life Warrenty.years],ShipmentData_ICF_T[ProductMaster.prod221],ProductFamily)*12
VAR LastCurrentDate = EOMONTH(
    MAX (ShipmentData_ICF_T[invoicemonth]),0)
VAR Period =
    DATESINPERIOD ( 'Calender'[Date], LastCurrentDate, - NumOfMonths, MONTH )
VAR Result = 
    CALCULATE ( 
        SUMX( 
            VALUES ( 'Calender'[Date] ), 
           ShipmentData_ICF_T[ShipQTY_T]
        ),
        Period, ShipmentData_ICF_T[ProductMaster.prod221] =ProductFamily
    )
VAR FirstDateInPeriod = MINX ( Period, 'Calender'[Date] )
VAR LastDateWithSales = EOMONTH(MAX ( ShipmentData_ICF_T[invoicemonth] ),0)
RETURN
    IF ( FirstDateInPeriod <= LastDateWithSales, Result )

 

Third DAX is : 

Overall_LT_ICF% = DIVIDE([LTFail-WC],[LTShipment-WC])

 

How to Bring all these in one.  I will plot this on a line chart for plotting trends over time series.

2 REPLIES 2
AlB
Super User
Super User

Hi @kuldeepjain 

What do you mean exactly by "bring all these in one"?

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

Bring in one means, the first two dad are giving me rolling sum and the third will calculate the %

 

If I can do all these three step in one day, my queries will be short and I need not to write 3 dad for each product type.

Helpful resources

Announcements
Winner of T-Shirt Design

Power BI T-Shirt Design Challenge 2023

Find out who won the T-Shirt Design Challenge and the top 3 finalists.

March 2023 Update3

Power BI March 2023 Update

Find out more about the March 2023 update.