cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
LeaRupnik
Helper III
Helper III

SQL Statment to DAX

Hello, 

a have sql statment, how to do this in dax.

select
CAST(sum([CPP Real_pro_kol])/1000 as INT) as sum_Real_pro_kol
,[CPP Datum_posnetka] as datum_posnetka
,year([CPP Datum_posnetka]) as leto_posnetka
,month([CPP Datum_posnetka]) as mesec_posnetka
,[CPP Leto] as leto
,[CPP Mesec] as mesec
from
[cisppr].[f CPP Cista prodajna premija] t1
inner join
(
select
max([CPP Datum_posnetka]) as leto_Datum_posnetka
from
[cisppr].[f CPP Cista prodajna premija]
group by
year([CPP Datum_posnetka])
,month([CPP Datum_posnetka])
) as t2 on t1.[CPP Datum_posnetka]= t2.leto_Datum_posnetka
where
[CPP Datum_posnetka] <= '2022-03-28'
--[CPP Datum_posnetka] <= '2020-12-31'
--and [CPP Leto] =2021



group by
year([CPP Datum_posnetka])
,month([CPP Datum_posnetka])
,[CPP Datum_posnetka]
,[CPP Leto]
,[CPP Mesec]
order by
year([CPP Datum_posnetka])
,month([CPP Datum_posnetka])
,[CPP Datum_posnetka]
,[CPP Leto]
,[CPP Mesec]

 

thx

LEa

1 ACCEPTED SOLUTION

Hello

I am adding a description of what I need. I have data entered in the table for each day. I would like to return only for maximum data in each year plus month. That is, for 2020 and January, I would only need data from 31.1.2020

 

thanks

Lea

View solution in original post

3 REPLIES 3
v-luwang-msft
Community Support
Community Support

Hi @LeaRupnik ,

Could you pls share some sample data ,and what you get final by the sql . Remember to remove confidential data.

 

 

Best Regards

Lucien

Greg_Deckler
Super User
Super User

@LeaRupnik These generally go better if you provide sample data and expected output versus the SQL code. Sorry, having trouble following, can you post sample data as text and expected output?
Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...

Hello

I am adding a description of what I need. I have data entered in the table for each day. I would like to return only for maximum data in each year plus month. That is, for 2020 and January, I would only need data from 31.1.2020

 

thanks

Lea

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.