Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

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 of the first table

- Sum of the amount from the first table

- Countrows of the second table

- Sum of the amount from the second table

 

I want to add 2 columns to my SUMUP table:

- A countrows if 'table 3'[fruit] = "Apple" distribued for each month 

- A countrows if 'table 3'[fruit] = "banana" distribued for each month 

 

I created a pbix file in order to give you some view over my datas.

 

Best regard,

 

ScrappyS

1 ACCEPTED SOLUTION

@Anonymous 

 

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

1.PNG

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)

4.PNG

Hope this is helpful.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

6 REPLIES 6
v-diye-msft
Community Support
Community Support

Hi @Anonymous 

 

If you've fixed the issue on your own please kindly share your solution. if the above posts help, please kindly mark it as a solution to help others find it more quickly. If not, please kindly elaborate more. thanks!

 

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.
ryan_mayu
Super User
Super User

@Anonymous 

 

Is this what you want?

column = CALCULATE(COUNTROWS(Feuil1),FILTER(Feuil1,Feuil1[Fruit]=earlier(Feuil1[Fruit])&&Feuil1[Month]=EARLIER(Feuil1[Month])))

1.PNG

If not, please share the expected result that you want.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

@ryan_mayu  

 

No, my table looks like that : 

 

2020-06-18 16_44_41-.png

 

Best regards

@Anonymous 

 

Could you please share the sample data?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

@ryan_mayu  sure you can find it here

@Anonymous 

 

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

1.PNG

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)

4.PNG

Hope this is helpful.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors