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
Swamy3105
Helper IV
Helper IV

Need urgent help please

Hi Experts,

 

I need realy urgent help.

 

I have the data with Actual and Plan with 2018 Whole year data, and 2019 with the current month (March) data.

 

I just calculated the max month, but it's not working. because when i select the 2019 in the slicer it's working fine, because i have the data till march, but when i select the 2018, it's showing the Decemeber month's data, because in 2018 the max month is December. even if I select the 2018 data it should show the March month data only.

 

How to do that, please help, I have a POC with my stakeholder tomorrow. I do not want to add the month slicer.

 

Please help......

1 ACCEPTED SOLUTION

@Swamy3105  Thanks for the sample data.  Please add a New Column to the table as below

 

MaxFlag = 
VAR _MaxYear = MAX(Test299Slicer[Year])
VAR _MaxPeriod = MAXX(FILTER(Test299Slicer,Test299Slicer[Year]=_MaxYear),Test299Slicer[Period])
RETURN IF(Test299Slicer[Period]=_MaxPeriod,"Y","N")

image.pngThen add a New Measure as below

Test299 = CALCULATE(SUM(Test299Slicer[Amount]),Test299Slicer[MaxFlag]="Y")

image.pngimage.png





Did I answer your question? Mark my post as a solution!

Proud to be a PBI Community Champion




View solution in original post

7 REPLIES 7
PattemManohar
Community Champion
Community Champion

@Swamy3105  If I've understood your problem statement correctly, you always want to show the current month data for previous years as well (even if the data is available for whole year). It will be really helpful and quicker if you can share the sample test data and expected output.





Did I answer your question? Mark my post as a solution!

Proud to be a PBI Community Champion




Hi,

 

Yes you are correct.

Year           Period           Amount

2018             1                     100

2018             2                     200

2018             3                     300  

2018             4                     400

2018             5                     500

2018             6                     600

2018             7                     700

2018             8                     800

2018             9                     900

2018            10                    1000

2018            11                     500

2018            12                     750

2019             1                      540 

2019             2                      610 

 

If select the year in the slicer as 2019 the max month is for 2019 = 2 and the value should be 610

If select the year in the slicer as 2018 the value should be 200 which is Feb month value

 

 

@Swamy3105  Thanks for the sample data.  Please add a New Column to the table as below

 

MaxFlag = 
VAR _MaxYear = MAX(Test299Slicer[Year])
VAR _MaxPeriod = MAXX(FILTER(Test299Slicer,Test299Slicer[Year]=_MaxYear),Test299Slicer[Period])
RETURN IF(Test299Slicer[Period]=_MaxPeriod,"Y","N")

image.pngThen add a New Measure as below

Test299 = CALCULATE(SUM(Test299Slicer[Amount]),Test299Slicer[MaxFlag]="Y")

image.pngimage.png





Did I answer your question? Mark my post as a solution!

Proud to be a PBI Community Champion




one more help.

 

how to check the min period using the same logic.

@Swamy3105  If you want to have Min period then it will be same logic with slight modifications.... Add new column as below

 

MinFlag = 
VAR _MaxYear = MAX(Test299Slicer[Year])
VAR _MinPeriod = MINX(FILTER(Test299Slicer,Test299Slicer[Year]=_MaxYear),Test299Slicer[Period])
RETURN IF(Test299Slicer[Period]=_MinPeriod,"Y","N")

Then the New Measure will be

Test299Min = CALCULATE(SUM(Test299Slicer[Amount]),Test299Slicer[MinFlag]="Y")

image.pngimage.png





Did I answer your question? Mark my post as a solution!

Proud to be a PBI Community Champion




Excellent Man!!!!!

 

This is what i expected, really thank you so much !

 

 

Hi,

 

If you use a date table add a column relative nr of months example:
https://www.sqlbi.com/articles/reference-date-table-in-dax-and-power-bi/ 

this way you can create a dynamic measure and always display the current month (Example relative month = 0)

this will make your life a lot easier (also you can compare months a lot easier 0 and 12 are the same months in different years).

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.