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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
sarath_chandra
Helper III
Helper III

Dax Help

I have charge date (which is first day of each month) as column , and month wise column (first day of each month ) and stocks column.

 

i need if i select one month in date slicer (charge date) for example(01/03/2018) .

it should show future stocks value from stock column from 01/03/2018(month wise column) to 01/12/2018 (month wise column). (blue colour mentioned in future stock)

and it should show actual stock value from stock column - previous month of (month wise column) (01/01/2018 and 01/02/2018)(blue colour mentioned in actual stock )

and it dynamically take the values from previous month of selected charge date for future stock (mentioned in yellow colour )

 

i want to show it in line chart (actual stock and future stock).

please help me out 🙏

The data values are:

input.jpg

 

 

output.jpg

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

Hi @sarath_chandra ,

 

Please try:

First create a new table for slicer:

vjianbolimsft_0-1670292493513.png

Then apply these measures:

future stocks =
VAR _a =
    EDATE ( SELECTEDVALUE ( 'For slicer'[charge_date] ), -1 )
VAR _b =
    CALCULATE (
        MAX ( 'Table'[stocks] ),
        FILTER (
            ALL ( 'Table' ),
            [charge_date] = _a
                && [month-wise] = MAX ( 'Table'[month-wise] )
        )
    )
RETURN
    IF (
        MAX ( 'Table'[month-wise] ) < SELECTEDVALUE ( 'For slicer'[charge_date] ),
        _b,
        MAX ( 'Table'[stocks] )
    )

Actual Stocks =
IF (
    MAX ( 'Table'[month-wise] ) < SELECTEDVALUE ( 'For slicer'[charge_date] ),
    MAX ( 'Table'[stocks] )
)

Final output:

vjianbolimsft_1-1670292606612.png

Best Regards,

Jianbo 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

3 REPLIES 3
v-jianboli-msft
Community Support
Community Support

Hi @sarath_chandra ,

 

Please try:

First create a new table for slicer:

vjianbolimsft_0-1670292493513.png

Then apply these measures:

future stocks =
VAR _a =
    EDATE ( SELECTEDVALUE ( 'For slicer'[charge_date] ), -1 )
VAR _b =
    CALCULATE (
        MAX ( 'Table'[stocks] ),
        FILTER (
            ALL ( 'Table' ),
            [charge_date] = _a
                && [month-wise] = MAX ( 'Table'[month-wise] )
        )
    )
RETURN
    IF (
        MAX ( 'Table'[month-wise] ) < SELECTEDVALUE ( 'For slicer'[charge_date] ),
        _b,
        MAX ( 'Table'[stocks] )
    )

Actual Stocks =
IF (
    MAX ( 'Table'[month-wise] ) < SELECTEDVALUE ( 'For slicer'[charge_date] ),
    MAX ( 'Table'[stocks] )
)

Final output:

vjianbolimsft_1-1670292606612.png

Best Regards,

Jianbo Li

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

Thanks for reply . Great working perfectly. awesome to learn from you. 

sarath_chandra
Helper III
Helper III

@ERD @amitchandak @Jihwan_Kim please help me out from this 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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