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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
nanacobsbs
Helper I
Helper I

Dax comand for card visual

I would like to have a card next to a graph visualizing sales performance and Target, showing the ratio to Target for the month selected by the slicer.
I would also like to set a threshold value and have it configured to change the background of the card depending on the value.
I created the following code, but when I put it in the card, it is blank and I cannot set the color.
Is it possible to have the numbers on the table appear on the card?

Please help again.

VS Target = IF(MAX('Calendar'[Date]) = MAX('Date for slicer'[Date]), DIVIDE(SUM('Budget Control'[Actual]),SUM('Budget Control'[Target])))

 

I have a sample pbix file and tried to upload here, but coudn't due to the follwing error message.
error  message:The file type (.pbix) is not supported.

What is wrong?

 

 

キャプチャ.GIF

1 ACCEPTED SOLUTION

does this work?

VS Target = VAR _date=VALUES('Date for slicer'[Date]) RETURN CALCULATE(DIVIDE(SUM('Budget Control'[Actual]),SUM('Budget Control'[Target])),TREATAS(_date,'Calendar'[Date]))

View solution in original post

4 REPLIES 4
wdx223_Daniel
Super User
Super User

because in the card visual, there is no filter context on the calendar table, so the condition of IF is FALSE, and give you a blank.

VS Target = VAR _date=MAX('Date for slicer'[Date]) RETURN CALCULATE(DIVIDE(SUM('Budget Control'[Actual]),SUM('Budget Control'[Target])),'Calendar'[Date]=_date)

Thank you for your reply.

I copied the dax code, but it is still blank.

nanacobsbs_0-1674793783988.png

 

 

does this work?

VS Target = VAR _date=VALUES('Date for slicer'[Date]) RETURN CALCULATE(DIVIDE(SUM('Budget Control'[Actual]),SUM('Budget Control'[Target])),TREATAS(_date,'Calendar'[Date]))

Yes!! It works!!!

Thank you very much.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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.