Forum Discussion

Elmar_Z's avatar
Elmar_Z
Regular Visitor
9 years ago
Solved

Aggregation items in the field

Hello!

 

I am rather new here - and I am need your help.

 

I try to calculate a repair rate of products in the field.

I have one table with the sold products during the time.

 

 

I have another DateTime Dimension Table.

 

And I need one measure/table that shows how many products are in the market since that date.

It is nearly like the "Year to date" Funktion - but it should not start at 0 at the next periode....

(this should be the base for the following repair rate)

 

 

Would be great, if anyone can give me a hint!

 

Thx a lot!!!!

Elmar

 

 

 

 

 

 

 

  • Hi Elmar

     

    I was not able to find a complete solution but might give you a hint nonetheless. 

     

    This formula in a new column basically does calculate what you're after (you might have to replace the semicolons with commas: 

     

    TotalSales = 
    SUMX(
    	FILTER(
    		Sales;
    		Sales[Date]<= EARLIER(Sales[Date]) && EARLIER(Sales[Type]) = Sales[Type]
    	);
    	Sales[Sold Amount]
    )

    I was not able to find a way to also display the values where it is blank now. 

     

    I hope this helps anyway...

    JJ

     

     

     

4 Replies

  • DoubleJ's avatar
    DoubleJ
    Icon for Solution Supplier rankSolution Supplier

    Hi Elmar

     

    I was not able to find a complete solution but might give you a hint nonetheless. 

     

    This formula in a new column basically does calculate what you're after (you might have to replace the semicolons with commas: 

     

    TotalSales = 
    SUMX(
    	FILTER(
    		Sales;
    		Sales[Date]<= EARLIER(Sales[Date]) && EARLIER(Sales[Type]) = Sales[Type]
    	);
    	Sales[Sold Amount]
    )

    I was not able to find a way to also display the values where it is blank now. 

     

    I hope this helps anyway...

    JJ

     

     

     

    • Elmar_Z's avatar
      Elmar_Z
      Regular Visitor

      Hello JJ!


      Thank you very much - that realy helped me a lot.

      Honestly - I don´t exactly understand, what the realy does - but it works.  ;) 

      Best regards,

      Elmar 

       

      amount of products in the market during the time

      • DoubleJ's avatar
        DoubleJ
        Icon for Solution Supplier rankSolution Supplier

        Hi Elmar_Z, sorry I skipped the explanation.  As we are both German speakers I try to explain in Deutsch :-)

         

        SUMX() iteriert alle Einträge in der Tabelle welche FILTER() zurückgibt. FILTER() wiederum iteriert alle Einträge in der Sales-Tabelle und filtert diese mit der Bedingung, welche im zweiten Argument definiert ist.

         

        Wir haben also 2 verschachtelte Iterationen. EARLIER() greift  innerhalb der inneren Iteration (FILTER) auf die aktuelle Zeile der äusseren Iteration (SUMX) zu. Die Filterbedingung liest sich also: Liefere alle Einträge der Sales-Tabelle, welche ein Datum haben das früher / gleich ist wie das Datum der Zeile der äusseren Iteration. Zudem muss es vom gleichen Type sein.

         

        Schlussendlich werden die Beträge so gefilterten Zeilen aufsummiert.

         

        Ich hoffe, das war einigermassen verständllich....