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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
fguijarrob
Frequent Visitor

Total by counting all records from a column if the cell contains 1

Hello,

I have created a column in a table writing 1 or 0 depending on the month and the year when the line was created and deleted.

If the month and year when the line was created is the same than when the line wsa deleted, I will write "1". Otherwise, I´ll write "0' 

 

 

T_F Mes de la linea = 
if(
    MONTH(linea_movil[fecha_inserccion]) = MONTH(linea_movil[fecha_baja_efectiva])&&
    YEAR(linea_movil[fecha_inserccion]) = YEAR(linea_movil[fecha_baja_efectiva]),
1,0)

 

 

I am trying to count from the column True_False I´ve created before all lines with value=1:

 

 

 

Total cells true = 
CALCULATE (
    COUNTROWS (lines) ,
    lines[True_False] IN {1})

 

 

 

However, I want to count only records with lines[true_false]=1 AND by filtering with the date column (dateCreated).

If I create a date filter on the visualization with

 fguijarrob_0-1661270797351.png   

and I chose a month by clicking the filter menu, the measure I´ve created is not filtering me by date.

It shows me the total of records=1 instead of filter all records=1 by counting only the month that I´ve choose in the filter.

How can I manage it?

Thank you for your help.

 

1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @fguijarrob ,

I created some data:

vyangliumsft_0-1661478720807.png

Here are the steps you can follow:

1. Create calculated table.

Table =
CALENDAR(MIN('linea_movi'[fecha_inserccion]),MAX('linea_movi'[fecha_inserccion]))

vyangliumsft_1-1661478720815.png

2. Create measure.

Flag =
var _min=MINX(ALLSELECTED('Table'),[Date])
var _max=MAXX(ALLSELECTED('Table'),[Date])
RETURN
IF( 
    MAX('linea_movi'[fecha_inserccion])>=_min&&MAX('linea_movi'[fecha_inserccion])<=_max&&MAX('linea_movi'[T_F Mes de la linea])=1
    ,1,0)
Measure =
COUNTX(ALLSELECTED('linea_movi'),[T_F Mes de la linea])

3. Place [Flag]in Filters, set is=1, apply filter.

vyangliumsft_2-1661478720816.png

4. Result:

vyangliumsft_3-1661478720823.png

 

If you need pbix, please click here.

Total by counting all records from a column if the cell contains 1.pbix

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

1 REPLY 1
v-yangliu-msft
Community Support
Community Support

Hi  @fguijarrob ,

I created some data:

vyangliumsft_0-1661478720807.png

Here are the steps you can follow:

1. Create calculated table.

Table =
CALENDAR(MIN('linea_movi'[fecha_inserccion]),MAX('linea_movi'[fecha_inserccion]))

vyangliumsft_1-1661478720815.png

2. Create measure.

Flag =
var _min=MINX(ALLSELECTED('Table'),[Date])
var _max=MAXX(ALLSELECTED('Table'),[Date])
RETURN
IF( 
    MAX('linea_movi'[fecha_inserccion])>=_min&&MAX('linea_movi'[fecha_inserccion])<=_max&&MAX('linea_movi'[T_F Mes de la linea])=1
    ,1,0)
Measure =
COUNTX(ALLSELECTED('linea_movi'),[T_F Mes de la linea])

3. Place [Flag]in Filters, set is=1, apply filter.

vyangliumsft_2-1661478720816.png

4. Result:

vyangliumsft_3-1661478720823.png

 

If you need pbix, please click here.

Total by counting all records from a column if the cell contains 1.pbix

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.