Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Countrows if for each month

Hello,   I have three tables, two with different type of code, each table has a code, an amount column and a date table.  I have a SUMUP table wich is construct like that : - Month - Countrows o...
  • ryan_mayu's avatar
    ryan_mayu
    6 years ago

    Anonymous 

     

    I didn't see table 3 in your sample file,so I created one.

    please see if this is what you want

    Table = 
    var t1=SUMMARIZE(ADDCOLUMNS('Table 1',"_month",month('Table 1'[Month])),[_month],"countrowT1",COUNTROWS('Table 1'),"SUM CA T1",SUM('Table 1'[CA]))
    var t2=SUMMARIZE(ADDCOLUMNS('Table 2',"_month",month('Table 2'[Month])),[_month],"countrowT2",COUNTROWS('Table 2'),"SUM CA T2",SUM('Table 2'[CA]))
    VAR t3=SUMMARIZE(ADDCOLUMNS('Table 3',"_month",month('Table 3'[Month])),[_month],"countapple",CALCULATE(COUNTROWS('Table 3'),FILTER('Table 3','Table 3'[fruit]="apple")),"countbanana",CALCULATE(COUNTROWS('Table 3'),FILTER('Table 3','Table 3'[fruit]="banana")))
    VAR t4=NATURALINNERJOIN(t1,t2)
    return 
    NATURALINNERJOIN(NATURALINNERJOIN(t1,t2),t3)

    Hope this is helpful.