Forum Discussion

EZV12's avatar
EZV12
Icon for Helper IV rankHelper IV
5 years ago

DAX formulas requests - please help

Dear all,

I urgently need your help to figure out some DAX formulas.

Here is the link https://1drv.ms/u/s!AnbNXrfr-X8jdCh4I-viYzEgvpw?e=kGjuRO for a sample file pbix. 

 

Here below please a picture in which I indicated my questions:

 

Many thanks in advance for your help.

Best regards

Rachel

8 Replies

  • selimovd's avatar
    selimovd
    Icon for Most Valuable Professional rankMost Valuable Professional

    Hey EZV12 ,

     

    where exactly are you struggling?

    What did you try and how should the result for the 3 cases look like?

     

    I don't totally understand what exactly the result should be.

     

    Best regards

    Denis

      • selimovd's avatar
        selimovd
        Icon for Most Valuable Professional rankMost Valuable Professional

        Hello EZV12 ,

         

        yes, those descriptions were more clear.

        I understood that you need a result like that:

         

        Here the measures I used.

        Measure for 1:

        Sum Shipped Parts = CALCULATE ( SUM('KPI data'[Value]), 'KPI data'[Data] = "ShippedParts")

         

        Measures for 2:

        ServiceRate = 
        VAR vShipments = CALCULATE ( SUM('KPI data'[Value]), 'KPI data'[Data] = "Shipments")
        VAR vShipmentDelay = CALCULATE ( SUM('KPI data'[Value]), 'KPI data'[Data] = "ShipmentDelay")
        RETURN
        DIVIDE( (vShipments  - vShipmentDelay ) , vShipments)

         

        ServiceRate Target = DIVIDE(CALCULATE ( SUM('KPI Target'[Value]), 'KPI Target'[KPI] = "ServiceRate") , 100)

         

        Measure for 3:

        Cumulated YTD ServiceRate = 
        VAR vShipments =
            CALCULATE(
                SUM( 'KPI data'[Value] ),
                'KPI data'[Data] = "Shipments"
            )
        VAR vShipmentsYTD =
            CALCULATE(
                SUM( 'KPI data'[Value] ),
                'KPI data'[Data] = "Shipments",
                DATESYTD( Calendar[Date] )
            )
        VAR vShipmentDelayYTD =
            CALCULATE(
                SUM( 'KPI data'[Value] ),
                'KPI data'[Data] = "ShipmentDelay",
                DATESYTD( Calendar[Date] )
            )
        RETURN
        IF (
            vShipments <> BLANK(),
            vShipmentsYTD - vShipmentDelayYTD
        )

         

        You can find my file here:

        https://www.swisstransfer.com/d/71431f2c-3490-4edb-a33f-15e31867b1fd

         

        In general you have to be aware that most of the results are coming from the context. So you don't say "Shipment for January + Shipment for February", you create the measure and then you use the month names as filter context for the formula. I know that's hard at the beginning and a totally different approach than Excel. Once you're used to that it's magic.

         

        If you need any help please let me know.
        If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
         
        Best regards
        Denis