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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
Smartnag
Frequent Visitor

Current month from year & month (format)

Hi All,

 

I have data like below table.

Source of data - Excel

 

Req -  calculate current year current month of A,B,C 

 

MonthABC
2021-000.2000.9000.650
2022-010.4000.660.23
2022-020.2000.9000.650
2022-030.4000.660.23
2022-040.2000.9000.650
2022-050.4000.660.23
2022-060.2000.9000.650
2022-070.4000.660.23
2022-080.2000.9000.650
2022-090.4000.660.23
2022-100.2000.9000.650
2022-110.4000.660.23
2022-120.4000.660.23
2022-000.4000.660.23

 

Please help me to write dax.

 

Thanks.

1 ACCEPTED SOLUTION
Duia
Resolver II
Resolver II

Hi @Smartnag ,

Here are the steps you can follow:
1. Create measure.

Flag =
var _flag=
VALUE(
LEFT(MAX('Table'[Month]),4))
var _currentyear=
YEAR(TODAY())
return
IF(
_flag=_currentyear,1,0)

2. Set [A], [B], [C] to Sum.

Duia_1-1660042023161.png

3. Place [Flag]in Filters, set is=1, apply filter.

Duia_2-1660042076083.png

4. Result:

Duia_3-1660042081281.png

If you need pbix, please click here.

Current month from year & month (format).pbix

Best Regards,
Liu Yang
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

2 REPLIES 2
Duia
Resolver II
Resolver II

Hi @Smartnag ,

Here are the steps you can follow:
1. Create measure.

Flag =
var _flag=
VALUE(
LEFT(MAX('Table'[Month]),4))
var _currentyear=
YEAR(TODAY())
return
IF(
_flag=_currentyear,1,0)

2. Set [A], [B], [C] to Sum.

Duia_1-1660042023161.png

3. Place [Flag]in Filters, set is=1, apply filter.

Duia_2-1660042076083.png

4. Result:

Duia_3-1660042081281.png

If you need pbix, please click here.

Current month from year & month (format).pbix

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

lbendlin
Super User
Super User

<checks calendar> yup, normal years still have 12 months, not 13.   What does "2021-00"  mean in your context?

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.