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
jasonwq
Helper I
Helper I

Creating a new column filtered by date

I'm having an issue where I want to retrieve certain sales information by date, but I don't want to filter the entire visual by that date.

 

ITEMENTRY_TYPEQUANTITYDATE
ASALE1008/1/2021

A

SALE1007/1/2021

A

SALE1001/1/2015

B

SALE2001/1/2015

B

SALE2001/1/2010

 

In the above scenario, I want to to end up with the following report:

 

ITEMRECENT SALES (Last 6 months)
A200
B0

 

I have gotten it to work half-way using filters (Date Filter>Relative> 6 months), but then item B does not show up on the report because it does not have any rows that meet the criteria.

 

Thanks for your help!

1 ACCEPTED SOLUTION

Hi @jasonwq ,

You can create a measure as below:

RECENT SALES (Last 6 months) = 
CALCULATE (
    SUMX (
        'Table',
        IF (
            DATEDIFF ( 'Table'[DATE], TODAY (), MONTH ) < 6
                && DATEDIFF ( 'Table'[DATE], TODAY (), MONTH ) >= 0,
            'Table'[QUANTITY],
            0
        )
    )
)

yingyinr_0-1629713253825.png

Best Regards

Community Support Team _ Rena
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

5 REPLIES 5
Samarth_18
Community Champion
Community Champion

Hi @jasonwq ,

 

You can add one if condition at last like below:-

return if(result = 0,0,result)

It will help you get items which are not having sales in 6 months but they are present.

 

Thanks,

Samarth

 

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

I don't understand. Where do I put that code?

 

Could you please share your code which you have written, I will add this code into it accordingly

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Sorry, I don't have any code written. I've been using the Filters in PowerBI but this is not working well for me.

 

 

Hi @jasonwq ,

You can create a measure as below:

RECENT SALES (Last 6 months) = 
CALCULATE (
    SUMX (
        'Table',
        IF (
            DATEDIFF ( 'Table'[DATE], TODAY (), MONTH ) < 6
                && DATEDIFF ( 'Table'[DATE], TODAY (), MONTH ) >= 0,
            'Table'[QUANTITY],
            0
        )
    )
)

yingyinr_0-1629713253825.png

Best Regards

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

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.