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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Analitika
Post Prodigy
Post Prodigy

Adding lines to visual in Power BI

Hi,

 

I would like to ask how to add lines by year. For example Lines number depends on filtered years. For example, we select two years (2022, 2021) and visual appears two lines according to these years. Now I have line which is accumulated values depends on selected years. So how to make that will be separate years lines in visual?

 

Current visual looks like this:

Analitika_0-1665066191780.png

 

2 REPLIES 2
v-chenwuz-msft
Community Support
Community Support

Hi @Analitika ,

 

Maybe you can try what if parameter with fields parameter.

vchenwuzmsft_0-1665123921541.png

 

Create measures for each year and use fields parameter for the line-y-axis of the chart.

Result:

vchenwuzmsft_1-1665124236563.gif

 

Pbix in the end you can refer.

Best Regards

Community Support Team _ chenwu zhu

 

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

 

Ok but if I have this measure for line current:

Pardavimai santykis_h = 
var metu_uzdarymo_pozymis=[ABC_Metu_uzdarymo_ZU0_KOD]
var valandos= CALCULATE([kiekis_h], all('Sas kod unik BRIDGE'[POZYMIAI Veiklu (Excel AUTO)]),all('Sas kod unik BRIDGE'[Sąskaitos pavadinimas]), all('Sas kod unik BRIDGE'[Pajamu sanaudu vaizdavimas (PAVADINIMAI)]),ALL('DBA view_DidknObj'[DID_NR]),ALL('DBA view_DidknObj'[DID_DAT]),ALL('DBA view_DidknObj'[OBJ_KOD]),ALL('DBA view_DidknObj'[Saskaitos numeris]),ALL('DBA klient_tiekejai'[kli_pav]))
/*var savikaina= sumx(FILTER('DBA view_DidknObj', RELATED('Sas kod unik BRIDGE'[POZYMIAI Veiklu (Excel AUTO)])="Savikaina"&&Find(metu_uzdarymo_pozymis,'DBA view_DidknObj'[ZU0_KOD],,0)=0), 'DBA view_DidknObj'[SUM_DEB]-'DBA view_DidknObj'[SUM_CRE])*/
return


if([kiekis_h]=BLANK(),"",DIVIDE([_2_1_1_Pardavimai (priklauso nuo vienetų pasirinkimo)],valandos))

Visual type is line and clustered column chart. So how change in my case? How I should change my measure in this case?

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors