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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

create a new column or measure with filter data from another column

Hi :

I want to create a new column  or measure by dax, but i don't know how. The conditions like below.

Here i have a table with 3 column call "sales data".

Billing date    

AOP

 AOP$ 

New column

2021/1/1

AOP

123.00

 

2021/1/1

Actual

2,466.00

 

2021/2/2

AOPJAN

31,655.00

 

2021/6/6

AOPJAN

13,345.00

 

2021/6/6

AOPJUL

5,623.00

 

2022/3/3

AOPJAN

56,677.00

 

2022/8/8

AOPJAN

46,267.00

 

 

1.if AOP=Actual or AOP,  [new column]=0

2.If  Year-Quarter, there has AOPJUL, [new column] = AOP$,

   and the same Year-Quarter which AOP=AOPJAN, [new column] = 0

3.If Year-Quarter dosen't exit AOP = AOPJUL, [new column] = AOP$ (which AOP = AOPJAN)

 

 

For example :

Billing date    

(example)      

AOP     

 AOP$      

New column

2021/1/1

2021-Q1

AOP

        123.00

0

2021/1/1

2021-Q1

Actual

        2,466.00

0

2021/2/2

2021-Q1

AOPJAN

31,655.00

31,655.00

2021/7/7

2021-Q3

AOPJAN

   13,345.00

0

2021/7/7

2021-Q3

AOPJUL

    5,623.00

5,623.00

2022/3/3

2022-Q1

AOPJAN

56,677.00

56,677.00

2022/8/8

2022-Q3

AOPJAN

46,267.00

46,267.00

 

Thanks .

 

1 ACCEPTED SOLUTION

Hi @Anonymous 
Thank you for the clarifications.
See here sample file https://www.dropbox.com/t/exwkvsK4LPyEWe2B
I hope this soves your problem

New Column = 
VAR CurrentYearQuarter =
    YEAR ( 'Sales Data'[Billing date] ) * 10 + QUARTER ( 'Sales Data'[Billing date] )
VAR Result =
    SWITCH (
        TRUE (),
        'Sales Data'[AOP] IN { "AOP", "ACTUAL" }, 0,
        CALCULATE ( 
            DISTINCTCOUNT ( 'Sales Data'[AOP] ), 
            FILTER ( 'Sales Data', YEAR ( 'Sales Data'[Billing date] ) * 10 + QUARTER ( 'Sales Data'[Billing date] ) = CurrentYearQuarter 
                && NOT ( 'Sales Data'[AOP] IN { "AOP", "ACTUAL" } ) )
        )
            > 1, IF ( 'Sales Data'[AOP] = "AOPJAN", 0, 'Sales Data'[AOP$] ),
        'Sales Data'[AOP$]
    )
RETURN
    Result

View solution in original post

6 REPLIES 6
tamerj1
Super User
Super User

@Anonymous 

Are trying to create a calculted column (new column) or a measure (new measure)?

Anonymous
Not applicable

i am trying to create a new column but not yet successful.

can new column or new measure do what i want?

Hi Rebecca

both are possible but conditions you've provided are not so clear. Can you explain further?

Anonymous
Not applicable

Hi tamerj1

 

I wili have two AOP datas per year,

the first one (AOPJAN) shows the data for a whole year and the second (AOPJUL) shows the data for the second half of the year. So when my second data comes in, it has to replace the first data. for the second half of the year.(The original AOPJAN data in the second half of the year will be replaced by AOPJUL.)

1C840E1D-CCEB-4C0B-A182-67B1B1EB4FB7.jpg

Hi @Anonymous 
Thank you for the clarifications.
See here sample file https://www.dropbox.com/t/exwkvsK4LPyEWe2B
I hope this soves your problem

New Column = 
VAR CurrentYearQuarter =
    YEAR ( 'Sales Data'[Billing date] ) * 10 + QUARTER ( 'Sales Data'[Billing date] )
VAR Result =
    SWITCH (
        TRUE (),
        'Sales Data'[AOP] IN { "AOP", "ACTUAL" }, 0,
        CALCULATE ( 
            DISTINCTCOUNT ( 'Sales Data'[AOP] ), 
            FILTER ( 'Sales Data', YEAR ( 'Sales Data'[Billing date] ) * 10 + QUARTER ( 'Sales Data'[Billing date] ) = CurrentYearQuarter 
                && NOT ( 'Sales Data'[AOP] IN { "AOP", "ACTUAL" } ) )
        )
            > 1, IF ( 'Sales Data'[AOP] = "AOPJAN", 0, 'Sales Data'[AOP$] ),
        'Sales Data'[AOP$]
    )
RETURN
    Result
Anonymous
Not applicable

Hi @tamerj1 :

Thank you so much to solve my problem !!😁

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!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

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