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

Comparing Two period slicer selection

Hi ,

 

I have months under slicer and i want to arrive difference between two selected period based on the selection.

(Based on the latest month selcted and selected previous period)

 

Arriving perivious period value i am having zero with below dax calculatrion. can anyone help me out.

 

Previous period calculation i am not getting right values.

 

Mani_ms_0-1596973702175.png

Mani_ms_1-1596973728170.png

 

Thanks,

Mani

 

 

1 ACCEPTED SOLUTION

Hi @Mani_ms ,

I found that you filtered the group = BS in the matrix so I created a slicer for the group field and the following measure if I got it correctly:

Measure = 
VAR _group =
    SELECTEDVALUE ( 'FMA 011 CY'[Group] )
VAR _maxfis =
    CALCULATE (
        MAX ( 'FMA 011 CY'[Fiscal Year/Period] ),
        ALLSELECTED ( 'FMA 011 CY'[Fiscal Year/Period] )
    )
VAR _minfis =
    CALCULATE (
        MIN ( 'FMA 011 CY'[Fiscal Year/Period] ),
        ALLSELECTED ( 'FMA 011 CY'[Fiscal Year/Period] )
    )
VAR _max =
    CALCULATE (
        SUM ( 'FMA 011 CY'[Balance - Cumulative] ),
        'FMA 011 CY'[Group] = _group,
        'FMA 011 CY'[Fiscal Year/Period] = _maxfis
    )
VAR _min =
    CALCULATE (
        SUM ( 'FMA 011 CY'[Balance - Cumulative] ),
        'FMA 011 CY'[Group] = _group,
        'FMA 011 CY'[Fiscal Year/Period] = _minfis
    )
RETURN
    _max - _min

diff.png

Attached sample file: fille.pbix 

 

Best Regards,
Yingjie 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

12 REPLIES 12
v-yingjl
Community Support
Community Support

Hi @Mani_ms ,

Try like this measure:

Diff =
VAR _max =
    CALCULATE ( MAX ( 'Table'[Sales] ), ALLSELECTED ( 'Table'[Month] ) )
VAR _min =
    CALCULATE ( MIN ( 'Table'[Sales] ), ALLSELECTED ( 'Table'[Month] ) )
RETURN
    _max - _min

valuediff.png

 

Attached a sample file that hopes to help you: Comparing Two period slicer selection.pbix

 

Best Regards,
Yingjie Li

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

Hi, 

 

Thanks for your inputs, seems somehow i am missing the expected result. attached PBI file 

 

Mani_ms_1-1597039562137.png

Expected result

Mani_ms_0-1597039506424.png

would be great if you could help on this?

Thanks,

Mani

 

Hi @Mani_ms ,

Not certain how did your expected output calculate, for each group and slected month?

Could you please sharing a dummy .pbix file for further discussion? Remeber to replace the sensitive information in the file.

 

Best Regards,
Yingjie Li

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

@v-yingjl  Thanks for your input.

 

I am new to community , How to upload files in the community portal. i have business one drive there i can't share the information outside. could you pls suggest alernate way.

Hi @Mani_ms ,

You can upload the dummy file to OneDrive for Business etc which can store files and just share this file link in the community.

 

Best Regards,
Yingjie Li

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

@v-yingjl 

Please find the below dummy file for your reference. would be great if you could assist on this.

sample file 

 

Thanks

Mani

Hi @Mani_ms ,

I found that you filtered the group = BS in the matrix so I created a slicer for the group field and the following measure if I got it correctly:

Measure = 
VAR _group =
    SELECTEDVALUE ( 'FMA 011 CY'[Group] )
VAR _maxfis =
    CALCULATE (
        MAX ( 'FMA 011 CY'[Fiscal Year/Period] ),
        ALLSELECTED ( 'FMA 011 CY'[Fiscal Year/Period] )
    )
VAR _minfis =
    CALCULATE (
        MIN ( 'FMA 011 CY'[Fiscal Year/Period] ),
        ALLSELECTED ( 'FMA 011 CY'[Fiscal Year/Period] )
    )
VAR _max =
    CALCULATE (
        SUM ( 'FMA 011 CY'[Balance - Cumulative] ),
        'FMA 011 CY'[Group] = _group,
        'FMA 011 CY'[Fiscal Year/Period] = _maxfis
    )
VAR _min =
    CALCULATE (
        SUM ( 'FMA 011 CY'[Balance - Cumulative] ),
        'FMA 011 CY'[Group] = _group,
        'FMA 011 CY'[Fiscal Year/Period] = _minfis
    )
RETURN
    _max - _min

diff.png

Attached sample file: fille.pbix 

 

Best Regards,
Yingjie Li

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

Hi Yingjie Li, 

Thanks for your answer, seems to have worked for others!

I am trying to do the same thing, but have limited experience in writing DAX, can you share your pbix file again? 

Thanks a lot!

@v-yingjl  thank you very much. Its perfectly working as per my expectation..Thank you once again

Hi, 

 

Thanks for your input.

Its working for the Max and Min values and difference is am getting wrong number. 

 

Mani_ms_0-1597040248897.png

 

Greg_Deckler
Super User
Super User

@Mani_ms You may find this helpful - https://community.powerbi.com/t5/Community-Blog/To-bleep-With-Time-Intelligence/ba-p/1260000

Also, see if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...

 

But, not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Hi,

 

Material quite useful. Ultimately what i am trying to get output is based on the selected months want to identify the difference between the selected value . 

 

would be great if you could help on that.

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.