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
Alopez11
Regular Visitor

Count Data, Help Again

Hello, I need a hand with a Dax formula
I got the following data set:

Date          Time    T°   
1-1-2011   0:30     3

1-1-2011   01:00   3,5
1-1-2011   01:30   3
1-1-2011   02.00   3

Etc

I've made the following chart

Alopez11_0-1636989545273.png

 

With the Max and Min temperature of each day and 2 min and max lines at 10°C and 20°C

Now, what I need is to count all the days that the min temperature is over or equal to 10°C and the day before the max temperature was over or equal to 20°C to display in a labbel

Thanks you very much for the help

6 REPLIES 6
Anonymous
Not applicable

Hi @Alopez11 ,

 

So based on your data sample, the output should be:

Eyelyn9_0-1637283364098.png

If so, please modify the Flag measure:

Flag = 
var _min=CALCULATE(MIN('Hoja1'[T°]),FILTER(ALL(Hoja1),[fecha]=MAX('Hoja1'[fecha])-1))
var _max=CALCULATE(MAX('Hoja1'[T°]),FILTER(ALL(Hoja1),[fecha]=MAX('Hoja1'[fecha])-1))
return 
CALCULATE(DISTINCTCOUNT(Hoja1[fecha]),FILTER('Hoja1',10<=_min && 20<=_max))

 

 

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

@Anonymous 
I'm really thankfull for your help,
I have to adapt a little bit the formula and i mannage to get the right flags, but I need to count hoy many flags I have in a labbel so I can tell, this month we hace 5 flags in example. How can I do that?

Alopez11_0-1637341984383.png

Flag =
var _min='Base de Datos'[T° Min]
var _max=CALCULATE(MAX('Base de datos'[T°]),filter(ALLSELECTED('Base de Datos'),'Base de Datos'[fecha]=max('Base de Datos'[fecha])-1))
return
CALCULATE(DISTINCTCOUNT('Base de datos'[fecha]),FILTER('Base de datos',10<=_min&&20<=_max)
)
Alopez11_1-1637342017171.png

 

 

Alopez11
Regular Visitor

Hello Evelyn
@Anonymous 

That formula works well, but we have 1 problem.
I need to count the "events" that the day before the max temperature is greater than 20°C and the min temperature is greater than 10°C

Example

Alopez11_0-1637240018153.png


Thanks!

 

Anonymous
Not applicable

Hi @Alopez11 ,

 

Please try the following formula to create a measure:

Flag = CALCULATE(DISTINCTCOUNT(Hoja1[fecha]),FILTER('Hoja1',10<=MIN('Hoja1'[T°]) && 20<=MAX('Hoja1'[T°])))

And apply it to filter pane to only show the date whose min>=10 and max>=20:

Eyelyn9_0-1637222994088.png

 

If you want to calculate the count of days, please use:

Count days = SUMX(VALUES(Hoja1[fecha]),[Flag])

Eyelyn9_1-1637223062189.png

 

 

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

Alopez11
Regular Visitor

Hello @lbendlin thanks for your replay, here you will find a table with data in the following link, I used One Drive to share it.

Data Example.xlsx

lbendlin
Super User
Super User

Please provide sanitized sample data that fully covers your issue. Paste the data into a table in your post or use one of the file services. 

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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.