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
AlanP514
Helper V
Helper V

Dax Error

Hai All I need help on this 
Requirement: Want to create a pie chart 
1 by default it should show max month otherwise it should show selected month v/s category column(column consist of different categorical values.
So I created a measure for this but that is showing an error.

AlanP514_1-1654926373422.png

This is the Measure I created but while applying 

AlanP514_2-1654926421953.png

AlanP514_4-1654926467983.png

I am getting this kind of error, please help me to rectify this 

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

@AlanP514 

Please try

 

CM =
VAR MaxMonth =
    CALCULATE ( MAX ( Initiative[Year Month] ), REMOVEFILTERS ( 'Calendar' ) )
VAR SelectedMonth =
    SELECTEDVALUE ( 'Calendar'[Year Month] )
VAR FinalMonth =
    IF ( [Is Year Filtered] = TRUE (), MaxMonth, SelectedMonth )
RETURN
    CALCULATE ( [# Model Number], 'Calendar'[Year Month] = FinalMonth )

 

View solution in original post

7 REPLIES 7
tamerj1
Super User
Super User

@AlanP514 

Please try

 

CM =
VAR MaxMonth =
    CALCULATE ( MAX ( Initiative[Year Month] ), REMOVEFILTERS ( 'Calendar' ) )
VAR SelectedMonth =
    SELECTEDVALUE ( 'Calendar'[Year Month] )
VAR FinalMonth =
    IF ( [Is Year Filtered] = TRUE (), MaxMonth, SelectedMonth )
RETURN
    CALCULATE ( [# Model Number], 'Calendar'[Year Month] = FinalMonth )

 

Hai @tamerj1 
Thanks this is working

Jihwan_Kim
Super User
Super User

Hi,

May I ask and please check how is the column 'Initiative'[Year Month] look like? Is it looking like the same as 'Calendar[Year Month Name] ?

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


AlanP514_0-1654930776342.png

Hai @Jihwan_Kim  Above  image from the calendar table and  below image from the initiative table

AlanP514_0-1654931085428.png

 

Please give a solution to rectify

Ashish_Mathur
Super User
Super User

Hi,

The Data type of _finalyear is alphanumeric (I assume) whereas the data type of Year_month is numeric.  that is reason fo the error.


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

Hai @Ashish_Mathur 

AlanP514_0-1654927216715.png

and for calendar i created fully as Dax

AlanP514_1-1654927250225.png

 

How to rectify this issue
 

Hi,

Do not create Year Month number and Year Month name columns.  Create 3 seperate columns - Year, Month name and Month number.


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

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.