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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
EduardoOrtega
Regular Visitor

Help with conditional formulas.

Good day,

I am new to using Power BI and I request your valuable help. I have the following set of data coming from a folder with very heavy Excel files:

EduardoOrtega_0-1682346830251.png

 

What I need is a formula or some way to help me determine, depending on the day (conciliation date column), which transactions were made on each day from March 1st to 31st based on the txn date column (which has the format "dd/mm/yyyy hh:mm:ss am, pm"), and classify them into 2 parameters: "Same period" and "Other period".

For "Same period", all transactions made from February 27th after 23:00:00 onwards, counting everything that is in March will be included. For "Other period", they will be those that are outside the previous range, whether before February 27th at 22:59:59 backwards, including other months and previous years.

I hope I have been able to explain the need well and that you can help me. Thank you very much.

3 REPLIES 3
v-rongtiep-msft
Community Support
Community Support

Hi @EduardoOrtega ,

I have created as simple sample, please refer to it to see if it helps you.

Create 2 columns.

max_time = FORMAT( dt"2023-3-31T23:59:59", BLANK(), "en-GB" )
min_time = FORMAT( dt"2023-2-27T23:00:00", BLANK(), "en-GB" )

Then create a measure.

Measure =
IF (
    MAX ( 'Table'[datetime] ) >= SELECTEDVALUE ( 'Table'[min_time] )
        && MAX ( 'Table'[datetime] ) <= SELECTEDVALUE ( 'Table'[max_time] ),
    "Same period",
    "Other period"
)

Or still use column.

column =
IF (
     ( 'Table'[datetime] ) >= earlier ( 'Table'[min_time] )
        &&  ( 'Table'[datetime] ) <= earlier ( 'Table'[max_time] ),
    "Same period",
    "Other period"
)

vrongtiepmsft_0-1682475430580.png

How to Get Your Question Answered Quickly 

 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Rongtie

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

 

 

First of all, thank you very much for your support, but I don't know how to use what you replied with my data or how to get the result. What you provided is very helpful, it's exactly what I want, I just don't know how to add it to my data. Beacuse i do not have those two tables min & max.

Hi @EduardoOrtega ,

You can create 2 columns.I used these two columns to fix the time.

vrongtiepmsft_0-1682557108396.png

Then change the result column.

Column = IF (
     ( 'Table'[datetime] ) >=  ( 'Table'[min_time] )
        &&  ( 'Table'[datetime] ) <=  ( 'Table'[max_time] ),
    "Same period",
    "Other period"
)

vrongtiepmsft_1-1682557812131.png

How to Get Your Question Answered Quickly 

 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Rongtie

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

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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