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
Dev_Pat
Frequent Visitor

MDX query for Specific Year

Hi Team,

I need a help to develop a MDX query.

Below is the detail requirement. Any help much appriciated.

 

A calculated column, which will give me 2019 volume number to respective month errecpective of any year in the row. Below is a sample table.

 Volume2019 Volume
1/1/202054.89 
2/1/202051.64 
3/1/202098.12 
4/1/202011.62 
5/1/202084.98 
6/1/202087.16 
7/1/202052.81 
8/1/202046.45 
9/1/202048.92 
10/1/202020.93 
11/1/202012.60 
12/1/202031.71 
1/1/20217.83 
2/1/202183.78 
3/1/202173.19 
4/1/202137.44 

 

Best Regards

Dev

5 REPLIES 5
v-jingzhang
Community Support
Community Support

Hi @Dev_Pat 

 

Can you provide the expected output based on your sample table? Currently I don't understand what should be the expected result. Thanks.

 

Regards,
Community Support Team _ Jing

Hi @v-jingzhang ,

Volume_2019 column is the expected column from first 4 column.

Can we write MDX code to get 5th column? irrespective of year in month column, can we get the number of 2019 in new calcuated column?

Thanks

MarketCategoryMonthVolumeVolume_2019
Market-1Category-11/1/202160.3939.16
Market-2Category-11/1/20200.5939.16
Market-3Category-11/1/201939.1639.16
     
Market-1Category-12/1/202135.1537.10
Market-2Category-12/1/202060.2537.10
Market-3Category-12/1/201937.1037.10
     
Market-1Category-13/1/202176.2055.40
Market-2Category-13/1/202033.5655.40
Market-3Category-13/1/201955.4055.40

Hi @Dev_Pat 

 

I don't know much about MDX. If it's possible to use DAX, you can use below codes:

Column =
CALCULATE (
    SUM ( 'Table'[Volume] ),
    ALL ( 'Table' ),
    YEAR ( 'Table'[Month] ) = 2019,
    MONTH ( 'Table'[Month] ) = MONTH ( EARLIER ( 'Table'[Month] ) )
)

072304.jpg

 

Regards,
Community Support Team _ Jing
If this post helps, please Accept it as the solution to help other members find it.

Hi @Dev_Pat 

 

I don't know much about MDX. If it's possible to use DAX, you can use below codes:

Column =
CALCULATE (
    SUM ( 'Table'[Volume] ),
    ALL ( 'Table' ),
    YEAR ( 'Table'[Month] ) = 2019,
    MONTH ( 'Table'[Month] ) = MONTH ( EARLIER ( 'Table'[Month] ) )
)

072304.jpg

 

Regards,
Community Support Team _ Jing
If this post helps, please Accept it as the solution to help other members find it.

Hi @Dev_Pat 

 

I don't know much about MDX. If it's possible to use DAX, you can use below codes:

Column =
CALCULATE (
    SUM ( 'Table'[Volume] ),
    ALL ( 'Table' ),
    YEAR ( 'Table'[Month] ) = 2019,
    MONTH ( 'Table'[Month] ) = MONTH ( EARLIER ( 'Table'[Month] ) )
)

072304.jpg

 

Regards,
Community Support Team _ Jing
If this post helps, please Accept it as the solution to help other members find it.

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.

Top Solution Authors
Top Kudoed Authors