Forum Discussion

richard_jackson's avatar
richard_jackson
Frequent Visitor
3 years ago
Solved

Category-split value divided by a calculated constant

Hi there!

 

I have a fact table which includes sales values with various different categories which can be split into "Main Sales" and "Other Sales" groupings (i.e. Category 1-3 = "Main", 4-6 = "Other"). Each entry has "Quantity" and "Value"

 

The client wants to have the "Other Sales" values split by categories, but all divided by the quantity which is the sum of "Main" sales.

 

Value of Other Sales (by Category) / SUM("Quantity" of "Main Sales").

 

This then needs to be provided with a weekly slicer and a YTD value.

 

What would be the best way to do this?

 

Thanks!

 

Rich

  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi richard_jackson ,

     

    Please check the formula:

    Column = 
    var a = CALCULATE(SUM('Table'[Value]),FILTER(ALLEXCEPT('Table','Table'[Week],'Table'[Category]),'Table'[Main]=0))+0
    var b = CALCULATE(SUM('Table'[Quantity]),FILTER(ALLEXCEPT('Table','Table'[Week]),'Table'[Main]=1))
    return
    a/b

     

     

5 Replies