Forum Discussion

madhushree's avatar
madhushree
Frequent Visitor
9 years ago

Need help for measure

Hi All,

 

For above table need to calculate a measure, that groups records on date and gives sum(amount)*distinctcount(key1).

i.e., 50*1+30*1 for 3/8/2017, 50*2 for 1/8/2017 and 50*1 for 2/8/2017.

Used below measure.But none are working as expected.

Measure1= CALCULATE( DISTINCTCOUNT(table1[key1])*FIRSTNONBLANK(table1[amount],table1[amount])

              For 3/8/2017 above measure gave 60. i.e., 30*2 as it takes firstnonblank as 30

Tried group by, summarise. None are working

4 Replies

  • vanessafvg's avatar
    vanessafvg
    Community Champion

    madhushree what is your expected outcome?

     

    just trying to undstand what you are doing

     

    can you take the example you pasted below and put what it would be if done correctly

     

     

  • Anonymous's avatar
    Anonymous
    Not applicable

    This may be an issue with the example, but isn't it just easiest to say

     

    Measure =
    SUMX(Table1,Table1[Amount]*Table1[Key1])

     

    That seems to do the trick for me. If you then put the date and the measure in a table that seems to produce the results you are after.

  • v-jiascu-msft's avatar
    v-jiascu-msft
    Microsoft Employee

    Hi madhushree,

     

    Maybe you can try this formula as a measure.

     

    Measure1 =
    SUMX (
        SUMMARIZE (
            'Table1',
            'Table1'[date],
            'Table1'[amount],
            "countkey1", DISTINCTCOUNT ( 'Table1'[key1] )
        ),
        'Table1'[amount] * [countkey1]
    )

     

     

     

     

     

     

     

     

     

     

     

     

     

    Best Regards!

    Dale

  • v-jiascu-msft's avatar
    v-jiascu-msft
    Microsoft Employee

    Hi madhushree,

     

    Could you please mark the proper answer as solution or share the solution if it's convenient for you? That will be a big help to the others.

     

    Best Regards!
    Dale