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

How to find difference of total count based on every month

Hello All, i am trying to find difference in total difference in the count of members each month. The goal is to use two slicer visuals for Months and a card visual which will show the difference of total count of member each month. so lets say that a user select January from one Slicer and February from another then the card visual should show the difference of total count. it could be either a positive value or negative.

 

any help or suggestions are appreciated.

 

Thanks in advance

 

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

Hi @rehman1 ,

 

One sample for your reference. Please check the following steps as below.

 

1. Create two calculated tables as below.

 

date1 = ADDCOLUMNS(CALENDARAUTO(),"ym",FORMAT([Date],"yyyymmmm"))
date2 = ADDCOLUMNS(CALENDARAUTO(),"ym2",FORMAT([Date],"yyyymmmm"))

2. To create a measure to get the excepted result.

Measure = 
VAR s1 =
    SELECTEDVALUE ( date1[ym] )
VAR s2 =
    SELECTEDVALUE ( date2[ym2] )
VAR a =
    CALCULATE (
        SUM ( 'Table'[value] ),
        FILTER ( 'Table', FORMAT ( 'Table'[date], "yyyymmmm" ) = s1 )
    )
VAR b =
    CALCULATE (
        SUM ( 'Table'[value] ),
        FILTER ( 'Table', FORMAT ( 'Table'[date], "yyyymmmm" ) = s2 )
    )
RETURN
    a - b

Capture.PNG

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

3 REPLIES 3
v-frfei-msft
Community Support
Community Support

Hi @rehman1 ,

 

One sample for your reference. Please check the following steps as below.

 

1. Create two calculated tables as below.

 

date1 = ADDCOLUMNS(CALENDARAUTO(),"ym",FORMAT([Date],"yyyymmmm"))
date2 = ADDCOLUMNS(CALENDARAUTO(),"ym2",FORMAT([Date],"yyyymmmm"))

2. To create a measure to get the excepted result.

Measure = 
VAR s1 =
    SELECTEDVALUE ( date1[ym] )
VAR s2 =
    SELECTEDVALUE ( date2[ym2] )
VAR a =
    CALCULATE (
        SUM ( 'Table'[value] ),
        FILTER ( 'Table', FORMAT ( 'Table'[date], "yyyymmmm" ) = s1 )
    )
VAR b =
    CALCULATE (
        SUM ( 'Table'[value] ),
        FILTER ( 'Table', FORMAT ( 'Table'[date], "yyyymmmm" ) = s2 )
    )
RETURN
    a - b

Capture.PNG

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
Ashish_Mathur
Super User
Super User

Hi,

Why do you need 2 slicers for months?  Just one slicer should do in which you can select a date range.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

You need 2 calendar tables. It’s probabaly easiest to have the second with an inactive relationship, then use USERELATIONSHIP and ALL

 

the first calendar table should be easy. 

 

The second with an Inactive relationship shouldn’t be something like

 

=CALCULATE(COUNTROWS(data),USERELATIONSHIP(Calendar2[date],data[date]),ALL(Calendar))

 

read more at the bottom of this article here https://exceleratorbi.com.au/multiple-relationships-between-tables-in-dax/



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

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.