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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
AlanP514
Post Patron
Post Patron

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.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

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
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors