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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
newgirl
Helper V
Helper V

Show daily volume with filtered date

Hello!

I have a sample volume table below and another table that is my calendar table.

DateVolClient
1-Jun-2210A
1-Jun-2220A
2-Jun-2230B
3-Jun-2220A
4-Jun-2230A
4-Jun-2210B
5-Jun-2230B
6-Jun-2240A
7-Jun-2210B
1-May-2210A
1-May-2220A
2-May-2230B
3-May-2220A
4-May-2230A
4-May-2210B
5-May-2230B
6-May-2240A
7-May-2210B
1-Jun-2110A
1-Jun-2120A
2-Jun-2130B
3-Jun-2120A
4-Jun-2130A
4-Jun-2110B
5-Jun-2130B
6-Jun-2140A
7-Jun-2110B

 

 

Is it possible to create this  page:

I have a slicer in the page that is always set to "Today" or the current date. I need in the same page a 'line and clustered column chart' that should show 3 fields - the volume of current month (Ex. June 2022), the volume of previous month (Ex. May 2022), and volume of same month as of current month but previous year (June 2021). The x-axis would then be the days of the month.

 

Another catch is that if the current date is if it's the 1st day of the month (Ex. July 1, 2022), it should treat the previous date (June 30, 2022) as the current month so that even on Day 1 of the month, the chart would still be able to show the previous month (June 2022), the previous-previous month (May 2022), and the same month as of previous month but previous year (June 2021).

 

See sample illustration below:

daily chart.JPG

 

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

Hi @newgirl ,

 

Please try these measures:

 

IsInCurrentMonth = 
IF (
    DAY ( TODAY () ) = 1,
    COUNTROWS (
        FILTER (
            'Calendar',
            'Calendar'[Date]
                >= TODAY () - 1
                && 'Calendar'[Date] <= EOMONTH ( TODAY (), 0 )
        )
    ),
    COUNTROWS (
        FILTER ( 'Calendar', 'Calendar'[YearMonthNum] = FORMAT ( TODAY (), "yyyymm" ) )
    )
)
current month = 
CALCULATE (
    SUM ( 'Table'[Vol] ),
    FILTER ( 'Calendar', [IsInCurrentMonth] <> BLANK () )
)
previous month = 
VAR Cur_month =
    CALCULATE (
        SUM ( 'Table'[Vol] ),
        FILTER (
            ALLSELECTED ( 'Calendar' ),
            'Calendar'[Date] = EDATE ( MAX ( 'Calendar'[Date] ), -1 )
        )
    )
RETURN
    IF ( [IsInCurrentMonth] <> BLANK (), Cur_month )
same month as of current month but previous year = 
VAR sameperiodlastyear_month =
    CALCULATE (
        SUM ( 'Table'[Vol] ),
        SAMEPERIODLASTYEAR('Calendar'[Date])
    )
RETURN
    IF (
        [IsInCurrentMonth] <> BLANK(), sameperiodlastyear_month
    )

vkkfmsft_0-1654492718592.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
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-kkf-msft
Community Support
Community Support

Hi @newgirl ,

 

Please try these measures:

 

IsInCurrentMonth = 
IF (
    DAY ( TODAY () ) = 1,
    COUNTROWS (
        FILTER (
            'Calendar',
            'Calendar'[Date]
                >= TODAY () - 1
                && 'Calendar'[Date] <= EOMONTH ( TODAY (), 0 )
        )
    ),
    COUNTROWS (
        FILTER ( 'Calendar', 'Calendar'[YearMonthNum] = FORMAT ( TODAY (), "yyyymm" ) )
    )
)
current month = 
CALCULATE (
    SUM ( 'Table'[Vol] ),
    FILTER ( 'Calendar', [IsInCurrentMonth] <> BLANK () )
)
previous month = 
VAR Cur_month =
    CALCULATE (
        SUM ( 'Table'[Vol] ),
        FILTER (
            ALLSELECTED ( 'Calendar' ),
            'Calendar'[Date] = EDATE ( MAX ( 'Calendar'[Date] ), -1 )
        )
    )
RETURN
    IF ( [IsInCurrentMonth] <> BLANK (), Cur_month )
same month as of current month but previous year = 
VAR sameperiodlastyear_month =
    CALCULATE (
        SUM ( 'Table'[Vol] ),
        SAMEPERIODLASTYEAR('Calendar'[Date])
    )
RETURN
    IF (
        [IsInCurrentMonth] <> BLANK(), sameperiodlastyear_month
    )

vkkfmsft_0-1654492718592.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
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.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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