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

Prepping for a Fabric certification exam? Join us for a live prep session with exam experts to learn how to pass the exam. Register now.

Reply
fabricbeta007
Regular Visitor

sales analysis

Hello I have a following Power BI query to solve.

 

Tasks:

    • 1. Data Import and Transformation: o Import the data into Power BI.
    • o Create a relationship between the Region and Product tables.
    • o Pivot the data to create a table with columns: Date, Region, Product, and SalesAmount.
    •  
    • 2. DAX Formulas: o Create a calculated column that calculates the year-to-date (YTD) sales.
    • o Calculate the total sales for each region using DAX measures.
    • o Calculate the top-selling product for each region

      Can someone help ? I am new to power bi
2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

Hi @fabricbeta007 ,

I don't think it's necessary if there's no clear need for it. Pivoting affects the creation of visuals.

You just need to make sure the data is arranged in this way.

vzhouwenmsft_0-1720506229958.png

 

Best Regards,
Wenbin Zhou

View solution in original post

Ok that great. I got it now. Thanks Wenbin!

View solution in original post

8 REPLIES 8
Anonymous
Not applicable

Hi @fabricbeta007 ,

1.Regarding your question, you should have completed this part of the task.

vzhouwenmsft_0-1720488519596.png

2.vzhouwenmsft_2-1720490485233.png

You can do pivot and unpivot here.

vzhouwenmsft_1-1720490470884.png

3.vzhouwenmsft_3-1720491098818.png

You can create similar DAX expressions using the 'TOTALYTD' function.

TOTALYTD function (DAX) - DAX | Microsoft Learn

Column = TOTALYTD(SUM('Table'[Amount]),'Table'[Date].[Date],ALLEXCEPT('Table','Table'[Region]))

 

vzhouwenmsft_4-1720491175502.png

4.vzhouwenmsft_5-1720491205345.png

Use the following DAX expression to create a measure.

Measure = SUM('Table'[Amount])

vzhouwenmsft_6-1720491372169.png

5.vzhouwenmsft_7-1720491410033.png

The Table data is shown below:

vzhouwenmsft_8-1720491839581.png

Use the following DAX expression to create a measure

Measure = 
CONCATENATEX(FILTER('Table','Table'[Amount] = MAX('Table'[Amount])),[Product],",")

CONCATENATEX function (DAX) - DAX | Microsoft Learn

vzhouwenmsft_9-1720491950183.png

 

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

 

 

Hi

Thanks for your reply.

Regarding unpivot and pivot I know how to do it. But I don't understand what to pivot .

 

Also I don't understand the reason behind doing unpivot and pivot in this data. Is it necessary here ?Could you please explain?

Screenshot 2024-07-08 at 19.04.33.png

Anonymous
Not applicable

Hi @fabricbeta007 ,

As I understand it, pivot just lets you look at the data from another angle.

vzhouwenmsft_0-1720502526438.png

If you perform a pivot operation in Power query, it is not conducive to building visuals in Power BI Desktop, so perform an unpivot operation.

You don't seem to have performed a pivot operation in your step, and a unpivot operation seems to be unnecessary.

vzhouwenmsft_1-1720502912900.png

 

Best Regards,
Wenbin Zhou

Ahh I see. But is pivoting necessary ?

Anonymous
Not applicable

Hi @fabricbeta007 ,

I don't think it's necessary if there's no clear need for it. Pivoting affects the creation of visuals.

You just need to make sure the data is arranged in this way.

vzhouwenmsft_0-1720506229958.png

 

Best Regards,
Wenbin Zhou

Ok that great. I got it now. Thanks Wenbin!

Ok that great. I got it now. Thanks Wenbin!

fabricbeta007
Regular Visitor

  • ModellingModellingDataData
  •  
  •  
  • datadata

 

 

I have done some data cleaning and  modelling from my end . Don't know if its correct or not.

Helpful resources

Announcements
May PBI 25 Carousel

Power BI Monthly Update - May 2025

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

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

May 2025 Monthly Update

Fabric Community Update - May 2025

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