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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
pani_victoria
Helper III
Helper III

sales by date and by month in one measure

Hello!

I have sales by product and a slicer by date "BEFORE".
The result I want to get in one measure is:
- if no date is selected in the slicer, then sales for the month (MTD)
- if a date is selected in the slicer, then sales for that date.
Is this possible and how?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Thanks solution from @vicky_ , your solution is great!

Hi, @pani_victoria 

Based on your description, I have created the following sample data:

vjianpengmsft_0-1713855262820.png

I have the following two measures:

vjianpengmsft_1-1713855311063.png

vjianpengmsft_2-1713855371031.png

I created a date table using the following DAX expression:

Table 2 = CALENDAR(MIN('Table'[Date]),TODAY())

I'm using columns from the entire date table in the slicer:

vjianpengmsft_3-1713855476101.png

I use the following DAX expression to create a measure that switches the MTD to the current day's breakdown:

sales =
VAR _seleteddate =
    SELECTEDVALUE ( 'Table 2'[Date] )
RETURN
    IF (
        ISBLANK ( _seleteddate ),
        [Sales MTD],
        CALCULATE ( [Sales amount], 'Table'[Date] = _seleteddate )
    )

Here are the results:

When the date slicer is not checked, the MTD is displayed:

vjianpengmsft_4-1713855671123.png

If the date is selected, the details of the current day are displayed:

vjianpengmsft_5-1713855742436.png

I've provided the PBIX file used this time below.

 

 

 

 

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

Jianpeng Li

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

2 REPLIES 2
Anonymous
Not applicable

Thanks solution from @vicky_ , your solution is great!

Hi, @pani_victoria 

Based on your description, I have created the following sample data:

vjianpengmsft_0-1713855262820.png

I have the following two measures:

vjianpengmsft_1-1713855311063.png

vjianpengmsft_2-1713855371031.png

I created a date table using the following DAX expression:

Table 2 = CALENDAR(MIN('Table'[Date]),TODAY())

I'm using columns from the entire date table in the slicer:

vjianpengmsft_3-1713855476101.png

I use the following DAX expression to create a measure that switches the MTD to the current day's breakdown:

sales =
VAR _seleteddate =
    SELECTEDVALUE ( 'Table 2'[Date] )
RETURN
    IF (
        ISBLANK ( _seleteddate ),
        [Sales MTD],
        CALCULATE ( [Sales amount], 'Table'[Date] = _seleteddate )
    )

Here are the results:

When the date slicer is not checked, the MTD is displayed:

vjianpengmsft_4-1713855671123.png

If the date is selected, the details of the current day are displayed:

vjianpengmsft_5-1713855742436.png

I've provided the PBIX file used this time below.

 

 

 

 

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

Jianpeng Li

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

 

 

vicky_
Super User
Super User

From the wording, I assume that you have a single-date slicer.
If so, then you can try wrap your calculations in an if statement. Something like:

Your Measure = IF(HASONEVALUE('Slicer Table'[Date]), 
    // ... your calculations for sales
    , // your calculations for MTD
)

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.