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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
cmath
Regular Visitor

Splitting numbers between months given start and end dates

Hello @amitchandak ,

 

Looking for assistance with some calculations. I have a data table with some of the columns as below

 

IDStart DateEnd DateRun Start DateRun End DateExpected Sales
14/01/202320/04/2023  10
26/02/202315/05/202318/05/202325/05/20235
320/01/20234/03/2023  2
431/01/20231/02/202310/02/202325/02/202320
520/02/202325/02/202326/02/20235/05/202315

 

Output required:

  • Splitting sales by month plotted on a graph
  • Counting the number of unique IDs by month plotted on a graph

***For Jan, the number of expected sales would be 13.16 and for Feb it will 29.4

***No. of unique runs in Jan will be 0 and for Feb will be 2

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

Hi @cmath ,

I created a sample pbix file(see the attachment), please find the details in it.

1. Create a date dimension table

2. Create a measure as below to get the count of IDs which fulfill the conditions

Count of IDs = 
VAR _selYM =
    VALUE ( SELECTEDVALUE ( 'Date'[YearMonth] ) )
RETURN
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[ID] ),
        FILTER (
            'Table',
            NOT ( ISBLANK ( 'Table'[Run Start Date] ) )
                && VALUE (
                    YEAR ( 'Table'[Run Start Date] ) & FORMAT ( 'Table'[Run Start Date], "MM" )
                ) <= _selYM
                && IF (
                    ISBLANK ( 'Table'[Run End Date] ),
                    1 = 1,
                    VALUE (
                        YEAR ( 'Table'[Run End Date] ) & FORMAT ( 'Table'[Run End Date], "MM" )
                    )
                ) >= _selYM
        )
    )

3. Create a visual as below screenshot

vyiruanmsft_1-1692173025295.png

And there is one doubt about the following requirement, what's the calculation logic of getting number of expected sales? Why is 13.16 for Jan and 29.4 for Feb? Could you please explain it with more details? Thank you.


***For Jan, the number of expected sales would be 13.16 and for Feb it will 29.4

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

1 REPLY 1
v-yiruan-msft
Community Support
Community Support

Hi @cmath ,

I created a sample pbix file(see the attachment), please find the details in it.

1. Create a date dimension table

2. Create a measure as below to get the count of IDs which fulfill the conditions

Count of IDs = 
VAR _selYM =
    VALUE ( SELECTEDVALUE ( 'Date'[YearMonth] ) )
RETURN
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[ID] ),
        FILTER (
            'Table',
            NOT ( ISBLANK ( 'Table'[Run Start Date] ) )
                && VALUE (
                    YEAR ( 'Table'[Run Start Date] ) & FORMAT ( 'Table'[Run Start Date], "MM" )
                ) <= _selYM
                && IF (
                    ISBLANK ( 'Table'[Run End Date] ),
                    1 = 1,
                    VALUE (
                        YEAR ( 'Table'[Run End Date] ) & FORMAT ( 'Table'[Run End Date], "MM" )
                    )
                ) >= _selYM
        )
    )

3. Create a visual as below screenshot

vyiruanmsft_1-1692173025295.png

And there is one doubt about the following requirement, what's the calculation logic of getting number of expected sales? Why is 13.16 for Jan and 29.4 for Feb? Could you please explain it with more details? Thank you.


***For Jan, the number of expected sales would be 13.16 and for Feb it will 29.4

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
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!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

Feb2025 NL Carousel

Fabric Community Update - February 2025

Find out what's new and trending in the Fabric community.