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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
AndradeRobson
Helper II
Helper II

DAX Function to Falculate Different Times

Dear, good afternoon!

 

Please could you help me I have two formulas in dax, one to calculate data until 30/09/2022 and another current formula to calculate from 01/10/2022.

 

I'm in need of a variable function that, when created, can apply these applications as I filter the data segmentation.

 

Example of the forms I have:

40_Difereca_Horas_=

"This calculation from 01/10/2022 onwards"
var current_function = CALCULATE([07_Difference_Horas_Contradas_Segurança])

 

"This calculates until 30/09/2022


var previous_function =
CALCULATE([24_Difference_Hours_Security])

 

Att.

 

Robson

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

Hi  @AndradeRobson ,

I created some data:

vyangliumsft_0-1668135450608.png

Here are the steps you can follow:

1. Create calculated column.

Group =
var _date1=DATE(2022,1,10)
var _date2=DATE(2022,9,30)
return
SWITCH(
    TRUE(),
'Table'[Date] >=_date1&&'Table'[Date]<_date2,1,
'Table'[Date]>=_date2,2
,3)

2. Create measure.

Measure =
SUMX(FILTER(ALL('Table'),'Table'[Group]=MAX('Table'[Group])),[Amount])

3. Result:

vyangliumsft_1-1668135450612.png

 

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  @AndradeRobson ,

I created some data:

vyangliumsft_0-1668135450608.png

Here are the steps you can follow:

1. Create calculated column.

Group =
var _date1=DATE(2022,1,10)
var _date2=DATE(2022,9,30)
return
SWITCH(
    TRUE(),
'Table'[Date] >=_date1&&'Table'[Date]<_date2,1,
'Table'[Date]>=_date2,2
,3)

2. Create measure.

Measure =
SUMX(FILTER(ALL('Table'),'Table'[Group]=MAX('Table'[Group])),[Amount])

3. Result:

vyangliumsft_1-1668135450612.png

 

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.