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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
rui_silva
Helper I
Helper I

Compare 2 months using Slicer

Hi,

i have a table where i need to compare values from 2 months using slicer, at this moment im using this measure:

Total LM = CALCULATE([nStudents];PREVIOUSMONTH('Month'[Data]) ) when i try to use this measure i dont get any result.

Sample Data

Data                        ClassName     nStudents       Total LM

01/01/2018               ClassA                30                  

01/02/2018               ClassA                25                  -5

 

My Month[Data] its already set as data table if it helps.

At my relationship i have

My class table as * to 1 for Month table.

My class table has IdMonth .

 

Rui Silva

1 ACCEPTED SOLUTION

@Greg_Deckler Thanks for all the help,

I managed to get solution using a invoked table with dates from 01/01/2018 to 31/12/2018 and its working as i would understand everytime i need to compares dates i cant uses tables i used from myself and need to create a invoked table with dates , etc 

Thanks ! 

Rui Silva

View solution in original post

7 REPLIES 7
Greg_Deckler
Super User
Super User

So, the sample data you presented, is that what you want to display as far as the Total LM, but you are not getting that result?


@ 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...

OK, so is the sample data presented (other than Total LM) represent your source data or are there some calculations going on there? So do you have 1 row for each month in your source data?


@ 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...

@Greg_Deckler So in my source data i have for each class 4 rows with diferent data and month as for example:

IDMonth IDClass ClassName        nStudents

1               CA       ClassA                      30

1               CB        ClassB                      30

2              CA          ClassA                     25

2               CB          ClassB                    25

3              CA         ClassA                     25

3               CB         ClassB                     20

4               CA          ClassA                    25 

4               CB         ClassB                      19

 

This is my source data the only calculation i had was the total os nStudents, and when i try to compare the months each others  when i put the measure in the table the result dont appear, Also i have Month table as Source

IDMonth        MonthName        Date

1                          January            01/01/2018

2                           February          01/02/2018

3                          March               01/03/2018

4                           April                 01/04/2018

 

My date column is formated to be the data table so i could compare the months.

OK, so since you do not have a true Date column, you are probably going to run into issues with the standard time intelligence functions. Check out my Time Intelligence "The Hard Way" Quick Measure here:

 

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

 

 


@ 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...

@Greg_Deckler  First of all Thanks for  the assistance,

About true Date Column what u mean with that ? 

Its is a column made with Dax / Power Query ?

 

@Greg_Deckler Thanks for all the help,

I managed to get solution using a invoked table with dates from 01/01/2018 to 31/12/2018 and its working as i would understand everytime i need to compares dates i cant uses tables i used from myself and need to create a invoked table with dates , etc 

Thanks ! 

Rui Silva

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.