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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
ajet-p_91
Frequent Visitor

how to select a product name in if condition dax

Hello everyone,

I am new to this forum.

I have a data table with columns for date, category, product, and price. I am seeking to create a DAX function to calculate the total price of a specific product for the previous year combined with the current year for one product-only current year price. My objective is to display the total price for the current year. How can I accomplish this task?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @ajet-p_91,

 

You don't need to create a DAX to fulfill your needs.

For the /Price/ column a numeric aggregation is automatically applied.

After adding the /Price/ column to the visual object, it will adaptively filter the display values based on the row and column labels.

 

For example, in the Matrix visualization object.

The rows labels are the /Product/ and /Date/ (year), and the value field is the /Price/.

 

The Price column will show the total price of each product for two years.

The next level down shows the total price of each product for last year and this year.

vdengllimsft_0-1724307289227.png

 

Another example is that you can add Product and Date fields to the slicer visual object.

You can manually choose to display the total price of which product for which year, or to display the total price for two years.

vdengllimsft_1-1724307306821.png

Best Regards,

Dengliang Li

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @ajet-p_91,

 

You don't need to create a DAX to fulfill your needs.

For the /Price/ column a numeric aggregation is automatically applied.

After adding the /Price/ column to the visual object, it will adaptively filter the display values based on the row and column labels.

 

For example, in the Matrix visualization object.

The rows labels are the /Product/ and /Date/ (year), and the value field is the /Price/.

 

The Price column will show the total price of each product for two years.

The next level down shows the total price of each product for last year and this year.

vdengllimsft_0-1724307289227.png

 

Another example is that you can add Product and Date fields to the slicer visual object.

You can manually choose to display the total price of which product for which year, or to display the total price for two years.

vdengllimsft_1-1724307306821.png

Best Regards,

Dengliang Li

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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