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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Clout
Helper III
Helper III

Counting rows between a specific timerange for every year

Hello guys,

 

I want to make a IF-Statement to count all values which exceeded a certain limit. But the limit only is there between the dates 1.5 and 1.11 (D.MM). I think this would be possible with declaring a specific start and end date. But my dataset goes from 2015 till 2021 and it is increasing. And I want to count the exceeded values for the another years too.

 

My Measure is now like this:

 

n_TN =
CALCULATE(COUNTROWS(Frachten),FILTER(Frachten, Frachten[AK_C_TN] <> Blank() && Frachten[AK_C_TN] > Max('Global'[GW_AblaufNges]))) + 0

 

But is there a way to only count the values between the timerange from 1.5 and 1.11 for every year?

 

Thanks in advance!

3 ACCEPTED SOLUTIONS
BA_Pete
Super User
Super User

Hi @Clout ,

 

You would add something like this into your measure:

n_TN =
CALCULATE(
  COUNTROWS(Frachten),
  FILTER(
    Frachten,
    Frachten[AK_C_TN] <> Blank()
    && Frachten[AK_C_TN] > Max('Global'[GW_AblaufNges])
    && MONTH(Frachten[Date]) IN {5, 6, 7, 8, 9, 10}
  )
) + 0

 

I'm assuming that your 01/11 (DD/MM) end date is actually only up to 31/10.

 

Pete

 



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

CNENFRNL
Community Champion
Community Champion

=
COUNTROWS(
    FILTER(
        Frachten,
        Frachten[AK_C_TN] <> BLANK()
            && Frachten[AK_C_TN] > MAX( 'Global'[GW_AblaufNges] )
            && MONTH( Frachten[Date] ) IN { 5, 6, 7, 8, 9, 10 }
    )
) + 0

Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

v-eqin-msft
Community Support
Community Support

Hi @Clout ,

 

I have built a simply data sample as shown below:

Frachten table sample.PNG

 

Based on my test, you could try the following formula to create a flag measure first:

Flag =
IF (
    MAX ( 'Frachten'[AK_C_TN] ) <> BLANK ()
        && MAX ( 'Frachten'[AK_C_TN] ) > MAX ( 'Frachten'[GW_AblaufNges] )
        && MONTH ( MAX ( 'Frachten'[Date] ) ) IN { 5, 6, 7, 8, 9, 10 },
    1,
    0
)

Then use SUMX() to sum Flag measure based on each year:

Measure = SUMX(FILTER('Frachten','Frachten'[Year]=MAX('Frachten'[Year])),[Flag])

Here is the final output :

Counting rows between a specific timerange for every year.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.

View solution in original post

4 REPLIES 4
v-eqin-msft
Community Support
Community Support

Hi @Clout ,

 

I have built a simply data sample as shown below:

Frachten table sample.PNG

 

Based on my test, you could try the following formula to create a flag measure first:

Flag =
IF (
    MAX ( 'Frachten'[AK_C_TN] ) <> BLANK ()
        && MAX ( 'Frachten'[AK_C_TN] ) > MAX ( 'Frachten'[GW_AblaufNges] )
        && MONTH ( MAX ( 'Frachten'[Date] ) ) IN { 5, 6, 7, 8, 9, 10 },
    1,
    0
)

Then use SUMX() to sum Flag measure based on each year:

Measure = SUMX(FILTER('Frachten','Frachten'[Year]=MAX('Frachten'[Year])),[Flag])

Here is the final output :

Counting rows between a specific timerange for every year.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.

BA_Pete
Super User
Super User

Hi @Clout ,

 

You would add something like this into your measure:

n_TN =
CALCULATE(
  COUNTROWS(Frachten),
  FILTER(
    Frachten,
    Frachten[AK_C_TN] <> Blank()
    && Frachten[AK_C_TN] > Max('Global'[GW_AblaufNges])
    && MONTH(Frachten[Date]) IN {5, 6, 7, 8, 9, 10}
  )
) + 0

 

I'm assuming that your 01/11 (DD/MM) end date is actually only up to 31/10.

 

Pete

 



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Hi @Clout ,

 

Can you let me know whether this answer worked for you or not please?

If it worked ok, please mark as the solution to help people with similar problems find the answer quicker.

 

Thanks,

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




CNENFRNL
Community Champion
Community Champion

=
COUNTROWS(
    FILTER(
        Frachten,
        Frachten[AK_C_TN] <> BLANK()
            && Frachten[AK_C_TN] > MAX( 'Global'[GW_AblaufNges] )
            && MONTH( Frachten[Date] ) IN { 5, 6, 7, 8, 9, 10 }
    )
) + 0

Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.